curl - Strange "JPEG datastream contains no image" with PHP -
i getting remote image , checking size of it.
sometimes strange error saying jpeg datastream contains no image
, narrowed down it's happening @ step, in fact it's happening @ imagecreatefromstring
. problem? issue image? or need increase kind of memory setting in php.ini or..?
function ranger($url) { $headers = array( "range: bytes=0-32768" ); $curl = curl_init($url); curl_setopt($curl, curlopt_httpheader, $headers); curl_setopt($curl, curlopt_returntransfer, 1); $data = curl_exec($curl); curl_close($curl); return $data; } $url = $prod['image1']; $raw1 = ranger($url); $im = imagecreatefromstring($raw1); $width = imagesx($im); $height = imagesy($im);
you need follow these 3 steps solve problem:
as error message states, not have image. need determine why not have image. start running
var_dump($raw1)
take @ algorithm in general. after step should know why not have image expected one.?
user valid image resource parameter of
imagecreatefromstring
.
Comments
Post a Comment