I'm trying to get an image from a website to use imagecreatefrompng (), but the result was never what I expected ...
Url: link 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">
TheproblemisthatwhenIcallcurlitreturnsthis:
GIF89a6>XXXLLL555AAAFFF))///_t#4ه*ílQЂ!(c) sulake!,6>H*\ȰÇ#JHŋ3jȱǏCIɓ(S\J-c ʘI͓(P@ѣpI2D"M Td˧ 5ʵ ( ? = Uk ׯ h vp @ 6e " E @ n, l @ ݝ & lt ; ^ 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;
I have tried to use file_get_contents but it is an https url and it does not work, I want it to return the image to be able to use with php's imagecreatefrompng ()
code I've 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);