Re: getimagetype() broken for jpegs?

From: Date: Wed, 02 Oct 2002 14:17:00 +0000
Subject: Re: getimagetype() broken for jpegs?
References: 1 2 3  Groups: php.dev 
Request: Send a blank email to php-dev+get-88859@lists.php.net to get a copy of this message
At 15:42 02.10.2002, Andrei Zmievski wrote:
On Wed, 02 Oct 2002, Rasmus Lerdorf wrote: Hrm... Actually, after a bit more checking it is only some jpegs that don't work. Specifically the ones coming from my digital camera are no longer working. Images that used to work with getimagesize() are now not, so I think something changed. Try running getimagesize() on this image: http://lerdorf.com/azj.jpg Yes, it doesn't work for me either. I don't see anything in image.c that would have changed, so it must be something in the streams code, perhaps?
Yes i just checked it. When i replace php_stream_seek() with php_stream_read() it works. cvs -z3 -q diff ext\standard\image.c (in directory S:\php4-HEAD\) Index: ext/standard/image.c =================================================================== RCS file: /repository/php4/ext/standard/image.c,v retrieving revision 1.69 diff -u -r1.69 image.c
--- ext/standard/image.c        18 Sep 2002 20:37:24 -0000      1.69
+++ ext/standard/image.c        2 Oct 2002 14:08:12 -0000
@@ -398,6 +398,7 @@
                {
                        return M_EOI;/* we hit EOF */
                }
+               php_error_docref( NULL TSRMLS_CC, E_NOTICE, "Reading:'0x%02X'", marker);
                if ( last_marker==M_COM && comment_correction>0)
                {
                        if ( marker != 0xFF)
@@ -436,7 +437,14 @@
        length = length-2;
        if (length)
        {
-               php_stream_seek(stream, (long)length, SEEK_CUR);
+               //php_stream_seek(stream, (long)length, SEEK_CUR);
+               unsigned char a[1];
+
+               while (length) {
+                       php_stream_read(stream, a, 1);
+                       length--;
+               }
+
        }
} /* }}} */ @@ -483,6 +491,7 @@
        for (;;) {
                marker = php_next_marker(stream, marker, 1, ff_read TSRMLS_CC);
                ff_read = 0;
+               php_error_docref( NULL TSRMLS_CC, E_NOTICE, "Marker: '0x%02X'", marker);
                switch (marker) {
                        case M_SOF0:
                        case M_SOF1:
When using this patch you will see all markers: Command line code(1) : Notice - getimagesize() [http://127.0.0.1/phpManual/function.getimagesize.html]: Reading:'0xE1' Command line code(1) : Notice - getimagesize() [http://127.0.0.1/phpManual/function.getimagesize.html]: Marker: '0xE1' Command line code(1) : Notice - getimagesize() [http://127.0.0.1/phpManual/function.getimagesize.html]: Reading:'0xFF' Command line code(1) : Notice - getimagesize() [http://127.0.0.1/phpManual/function.getimagesize.html]: Reading:'0xE2' Command line code(1) : Notice - getimagesize() [http://127.0.0.1/phpManual/function.getimagesize.html]: Marker: '0xE2' Command line code(1) : Notice - getimagesize() [http://127.0.0.1/phpManual/function.getimagesize.html]: Reading:'0xFF' Command line code(1) : Notice - getimagesize() [http://127.0.0.1/phpManual/function.getimagesize.html]: Reading:'0xE2' Command line code(1) : Notice - getimagesize() [http://127.0.0.1/phpManual/function.getimagesize.html]: Marker: '0xE2' Command line code(1) : Notice - getimagesize() [http://127.0.0.1/phpManual/function.getimagesize.html]: Reading:'0xFF' Command line code(1) : Notice - getimagesize() [http://127.0.0.1/phpManual/function.getimagesize.html]: Reading:'0xE2' Command line code(1) : Notice - getimagesize() [http://127.0.0.1/phpManual/function.getimagesize.html]: Marker: '0xE2' Command line code(1) : Notice - getimagesize() [http://127.0.0.1/phpManual/function.getimagesize.html]: Reading:'0xFF' Command line code(1) : Notice - getimagesize() [http://127.0.0.1/phpManual/function.getimagesize.html]: Reading:'0xDB' Command line code(1) : Notice - getimagesize() [http://127.0.0.1/phpManual/function.getimagesize.html]: Marker: '0xDB' Command line code(1) : Notice - getimagesize() [http://127.0.0.1/phpManual/function.getimagesize.html]: Reading:'0xFF' Command line code(1) : Notice - getimagesize() [http://127.0.0.1/phpManual/function.getimagesize.html]: Reading:'0xC4' Command line code(1) : Notice - getimagesize() [http://127.0.0.1/phpManual/function.getimagesize.html]: Marker: '0xC4' Command line code(1) : Notice - getimagesize() [http://127.0.0.1/phpManual/function.getimagesize.html]: Reading:'0xFF' Command line code(1) : Notice - getimagesize() [http://127.0.0.1/phpManual/function.getimagesize.html]: Reading:'0xDD' Command line code(1) : Notice - getimagesize() [http://127.0.0.1/phpManual/function.getimagesize.html]: Marker: '0xDD' Command line code(1) : Notice - getimagesize() [http://127.0.0.1/phpManual/function.getimagesize.html]: Reading:'0xFF' Command line code(1) : Notice - getimagesize() [http://127.0.0.1/phpManual/function.getimagesize.html]: Reading:'0xC0' Command line code(1) : Notice - getimagesize() [http://127.0.0.1/phpManual/function.getimagesize.html]: Marker: '0xC0' Before only the first marker was read: Command line code(1) : Notice - getimagesize() [http://127.0.0.1/phpManual/function.getimagesize.html]: Reading:'0xE1' Command line code(1) : Notice - getimagesize() [http://127.0.0.1/phpManual/function.getimagesize.html]: Marker: '0xE1' Command line code(1) : Notice - getimagesize() [http://127.0.0.1/phpManual/function.getimagesize.html]: Reading:'0x60' Command line code(1) : Notice - getimagesize() [http://127.0.0.1/phpManual/function.getimagesize.html]: Marker: '0xD9' Reading 0x60 suggests that the seeker function skips some bytes. Reading the next four bytes after the seek: 0x60 0x60 0x76 0xFF that suggests 3 bytes are missing since after the seek the next char to read must be 0xFF. marcus

« previous php.dev (#88859) next »