|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #21912 getimagesize() on remote images fails sometimes..
Submitted: 2003-01-27 16:12 UTC Modified: 2003-02-22 04:57 UTC
From: tozz at kijkt dot tv Assigned: wez (profile)
Status: Closed Package: GetImageSize related
PHP Version: 4.3.1-dev OS: Linux
Private report: No CVE-ID: None
 [2003-01-27 16:12 UTC] tozz at kijkt dot tv

I have a weird problem, which I think is a bug. The following script works with PHP 4.1.2 (I know, very outdated), but DOES NOT work with PHP 4.3.0:

error_reporting (E_ALL);

print ("<img src='$foto'>\n");
print ("<p>\n");
print ("width: $width; height: $height; type: $type<br>\n");

print ("<p>\n");

print ("<img src='$foto'>\n");
print ("<p>\n");
print ("width: $width; height: $height; type: $type<br>\n");

The problem is :

The first image works fine, it shows the height, width and type. However, the information about the second image is only beeing displayed if using PHP 4.1.2. With PHP 4.3.0 no information is beeing displayed.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2003-01-27 17:25 UTC]
I can reproduce this with latest stable CVS (4.3.1-dev)
It does work if the image is local..but not if it's remote.

 [2003-01-28 13:26 UTC] michael dot mauch at gmx dot de
php -r '$size = getimagesize(""); print_r($size); echo "\n";'

works without problems here (PHP 4.3.0), while

php -r '$size = getimagesize(""); print_r($size); echo "\n";'

prints nothing. ImageMagick's "identify" sees some strange ipct data in the second image; probably these make getimagesize() misbehave.
 [2003-01-28 13:52 UTC] tozz at kijkt dot tv
Yes, it has indeed something to do with the image. If I take another image it works fine! But there must be some difference in the PHP versions since the 2nd pictures only works with PHP 4.1.2, and not with the latest PHP version.
 [2003-02-08 05:41 UTC]
I suppose ther is another problem :-)

When i download the image and put it on one of my local servers it works:

[marcus@zaphod php4-HEAD]$ php -r 'print_r(getimagesize($argv[1]));' --
    [0] => 389
    [1] => 500
    [2] => 2
    [3] => width="389" height="500"
    [bits] => 8
    [channels] => 3
    [mime] => image/jpeg
[marcus@zaphod php4-HEAD]$ php -r 'var_dump(getimagesize($argv[1]));' --
 [2003-02-17 17:37 UTC] michael dot mauch at gmx dot de
Yes, it's the same here - on the local servers it works with both images, but it doesn't work with the 00645.jpg when I put it on another remote server.

When I change line 387 of ext/standard/image.c:

		if ((marker = php_stream_getc(stream)) == EOF)
		marker = php_stream_getc(stream);
		fprintf(stderr,"%0x ",marker);
		if (marker == EOF)

I see
  e0 ff ed ff ee ff db ff c0
when the image is served from localhost and only
  e0 ff ed 68
  e0 ff ed 64 
when fetching from the remote servers. That looks strange, but I'm afraid I don't understand what's going on here.
 [2003-02-17 18:23 UTC]
To <tozz at kijkt dot tv>:
  The difference is that we have a new streams abstraction 
  layer which allows GetImageSize() to work which whatever
  can be treated as a file.

To <michael dot mauch at gmx dot de>:
  That was what i expected. And it means there is a problem
  with the streams stuff.
 [2003-02-22 02:26 UTC] michael dot mauch at gmx dot de
Wez apparently fixed this one, too - php4-STABLE-200302220630 works for both pictures.
 [2003-02-22 04:57 UTC]
Let's close this report then.
I'm not quite sure what fixed this, but there were a number of minor problems with streams that could have all contributed to this problem.
Please re-open if it happens again.
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu May 30 19:01:32 2024 UTC