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("");
if($imgWidth > 400)
echo "<img width=400>";
echo "<img>";

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:


Fragmonster wrote:


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(

PHP General Mailing List (
To unsubscribe, visit:

Reply via email to