I'm getting the following error message using php's getimagesize on a small percentage (<5%) of image links tested...
getimagesize(): SSL: The specified procedure could not be found.
Here's an example that's throwing the error (on both my local/MAMP server and live version)...
getimagesize("https://cdn.meme.am/instances/500x/65858681.jpg");
Anyone have any ideas how to dig into this further? Really don't know where to go with it and couldn't find many similar questions. Thanks!
This code will do the trick for you
<?php
function getimgsize($url, $referer = '')
{
$headers = array(
'Range: bytes=0-32768'
);
/* Hint: you could extract the referer from the url */
if (!empty($referer)) array_push($headers, 'Referer: '.$referer);
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
$data = curl_exec($curl);
curl_close($curl);
$image = imagecreatefromstring($data);
$return = array(imagesx($image), imagesy($image));
imagedestroy($image);
return $return;
}
list($width, $heigth) = getimgsize('https://cdn.meme.am/instances/500x/65858681.jpg', 'https://cdn.meme.am/instances/');
echo $width.' x '.$heigth;
?>