|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #22120 GetImageSize seems confused on certain JPGs from certain hosts
Submitted: 2003-02-08 00:26 UTC Modified: 2003-02-08 02:10 UTC
From: 1413 at blargh dot com Assigned:
Status: Not a bug Package: GetImageSize related
PHP Version: 4.3.0 OS: Linux 2.2.19 (Debian)
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
Solve the problem:
17 + 12 = ?
Subscribe to this entry?

 [2003-02-08 00:26 UTC] 1413 at blargh dot com
GetImageSize() seems confused on certain JPGs from freeservers.  The JPG is valid (you can load it from your web-browser).

Script to reproduce:

$res = GetImageSize("");
if($res == FALSE)
  print("Erk! GetImageSize returned FALSE!");
} else {


$res = GetImageSize("");
if($res == FALSE)
  print("Erk! GetImageSize returned FALSE!");
} else {


The script SHOULD report:
Array ( [0] => 396 [1] => 178 [2] => 2 [3] => width="396" height="178" [bits] => 8 [channels] => 3 ) 
Array ( [0] => 800 [1] => 600 [2] => 2 [3] => width="800" height="600" [bits] => 8 [channels] => 3 ) 

And it does when I copy the file to my local Apache web server and change the script to point there instead.  It also works on a second server I have running PHP 4.1.2.

However, with the URL listed, under PHP 4.3.0, it reports:
Erk! GetImageSize returned FALSE!
Array ( [0] => 800 [1] => 600 [2] => 2 [3] => width="800" height="600" [bits] => 8 [channels] => 3 [mime] => image/jpeg ) 

Configuration options:
./configure  --with-apxs --with-zlib --with-bz2 --with-gd=/usr --enable-gd-native-ttf --with-mysql=/usr --enable-sockets --prefix=/usr --with-ttf --enable-ftp

Troubleshooting steps already taken:
- I tried copying the image to my local web server, changed the script to look there, and it works.
- Dozens of other JPGs on freeservers work as well.
- It seems this combination of server and image file is causing GetImageSize() to fail.  When I point my web browser at the same URL, the picture comes up. 
- I tried putting the picture into GIMP and resaving out - the re-saved image also has the same problems.  (This file is bug2.jpg at the same site.)
- Running 'identify -verbose' on the files shows perhaps the difference of Resolution (notbug.jpg is 300x300 pixels/inch, as are most of the other pictures, while bug.jpg and bug2.jpg are at72x72 pixels/inch) may be part of what's triggering it.
- I have re-downloaded the source, re-compiled and re-installed with the above options, with no change in results.
- Running the script from the command line has no change in results.

All-in-all, quite strange...


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2003-02-08 00:33 UTC] 1413 at blargh dot com
My apologies - it seems to work on bug2.jpg (the version loaded into GIMP and then resaved out.)
 [2003-02-08 02:10 UTC]
Please do not submit the same bug more than once. An existing
bug report already describes this very problem. Even if you feel
that your issue is somewhat different, the resolution is likely
to be the same. Because of this, we hope you add your comments
to the existing bug instead.

Thank you for your interest in PHP.

See bug #21912

PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Tue Aug 11 19:01:30 2020 UTC