4
I’m trying to get an image from a website to use imagecreatefrompng(), but the backlash was never what I expected...
Url: https://www.habbo.com.br/habbo-imaging/avatarimage?user=vfr&direction=3&size=m in the case when I call as <img>
works perfectly
<img src="https://www.habbo.com.br/habbo-imaging/avatarimage?user=vfr&direction=3&size=m">
the problem is that when I call Curl returns it:
Gif89a6> XXXXLLL555AAAFFF))//_t#4 ه* íl Q Ђ! (c) sulake! ,6> H * Ȱ Ç#J H ŋ3j ȱ Ǐ C I ɓ(S J -c �ʘ��I��͓(P�@ѣpI2���D�"M�Td˧�5ʵ(��?=� Ukׯh�vp�@۶e�"E@�n،l���@ݝ<�^d�voٿ�w�L����"HLy�b�� ?� [9q�� j~�����:AӤ��qD�o9���Z&��!� >p�3m�(
;3�CؓoS�s��3�H8�e��[.����t����߾�]�s�������4[ ��
z#5 @k _L <��7�~��t
*aKV nx }! # h B b . 0~@
8 H! Jėh>J ��/ӎ�g�&�4a�� )�7�!� /�$�Ӆ)�Kh���l���p�)�tB;
already tried to use file_get_contents but it’s a https url and it doesn’t work, I want you to return the image to use with imagecreatefrompng() from php
code I used:
function getimg($url) {
$headers[] = 'Accept: image/gif, image/x-bitmap, image/jpeg, image/pjpeg';
$headers[] = 'Connection: Keep-Alive';
$headers[] = 'Content-type: application/x-www-form-urlencoded;charset=UTF-8';
$process = curl_init($url);
curl_setopt($process, CURLOPT_URL, $url);
curl_setopt($process, CURLOPT_HEADER, false);
curl_setopt($process, CURLOPT_HTTPHEADER, array('Accept-Encoding: gzip, deflate, sdch'));
curl_setopt($process, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
curl_setopt($process, CURLOPT_RETURNTRANSFER, true);
curl_setopt($process, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($process, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($process, CURLOPT_SSL_VERIFYPEER, 0);
$return = curl_exec($process);
curl_close($process);
return $return;
}
echo getimg('https://www.habbo.com.br/habbo-imaging/avatarimage?user=vfr&direction=3&size=m');
//echo '<img src="'.getimg('https://www.habbo.com.br/habbo-imaging/avatarimage?user=vfr&direction=3&size=m').'">';
//$habbo = imagecreatefrompng('https://www.habbo.com.br/habbo-imaging/avatarimage?user=vfr&direction=3&size=m');
//imagecopy($im, $habbo, -2, -9, 0, 0, 33, 33);
Step face be wrong, but the
Content-Type:
shouldn’t beimage/jpeg
?– MagicHat
Oh... it seems that if you qualify in your
php.ini
theextension=php_openssl.dll
andallow_url_fopen = On
, you can usefile_get_content
... I don’t know, just ideas...– MagicHat
Tried something like
header('Content-type: image/png');
for example, to know if the image is mounted? The$process = curl_init($url);
can be$process = curl_init();
in your case, since you set the url using theCURLOPT_URL
.– Florida