Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Buy a domain name - Register cheap domain names from $0.99 - Namecheap

Scalable Hosting That Grows With You

Secure & Reliable Web Hosting, Free Domain, Free SSL, 1-Click WordPress Install, Expert 24/7 Support

Semrush - keyword research tool

Boost your online presence with premium web hosting and servers

Disclosure: My content contains affiliate links.

39,880 questions

51,806 answers

573 users

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 242 views
1 answer 171 views
2 answers 332 views
1 answer 207 views
1 answer 241 views
1 answer 228 views
...