No,no. I just want to display distant images on my site (from another site). But, in order to not crash my look, just before display the image I want to evaluate its size. If it is too large I put a width attribute in the <img> tag.

I want to do that:

$imgWidth = getWidth("www.toto.com/image.gif");
if($imgWidth > 400)
echo "<img src=www.toto.com/image.gif width=400>";
else
echo "<img src=www.toto.com/image.gif>";

I just want to know if it is possible to do the getWidth() function without download the image on the server.


Lokesh Setia wrote:

I dont believe that such a function would already exist. If saving network bandwidth is your aim, you can open an HTTP connection yourself, read only the first 10 bytes, and close the connection. The first six bytes of an GIF image is always 'GIF87a' or 'GIF89a'. Then comes the width as a 16-bit integer (LSB first), and then the height, also as a 16-bit integer.

see details of the format here:
http://www.daubnet.com/formats/GIF.html

hth
loki#


Fragmonster wrote:

Hi,

I want to resize an image from an URL if it is too large. Is there a way to know the size (width and height) of an image from an url without download it?

For exemple: getWidth(http://www.toto.com/imlage.gif)



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to