How to get remote image (from URL) width and height in PHP

3 Answers

0 votes
if (($img_size =  getimagesize("http://seek4info.com/images/seek4info_logo.png")) === false) 
    echo "error";

$width = $img_size[0];
$height = $img_size[1];

echo "w: " . $width . " h: " . $height;


/*
run: 

w: 236 h: 82 

*/

 



answered Jun 18, 2016 by avibootz
0 votes
list($width, $height) =  getimagesize("http://seek4info.com/images/seek4info_logo.png");

echo "w: " . $width . " h: " . $height;


/*
run: 

w: 236 h: 82 

*/

 



answered Jun 18, 2016 by avibootz
0 votes
$headers = array("Range: bytes=0-32768");
$curl = curl_init("http://seek4info.com/images/seek4info_logo.png");
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
$data = curl_exec($curl);
curl_close($curl);;

$img_size = imagecreatefromstring($data);
$width = imagesx($img_size);
$height = imagesy($img_size);

echo "w: " . $width . " h: " . $height;  


/*
run: 

w: 236 h: 82 

*/

 



answered Jun 18, 2016 by avibootz

Related questions

2 answers 257 views
1 answer 184 views
2 answers 344 views
1 answer 221 views
1 answer 260 views
1 answer 256 views
...