helly           Fri Jan 17 13:51:31 2003 EDT

  Added files:                 
    /php4/ext/standard/tests/image      test1pix.jp2 

  Modified files:              
    /php4/ext/standard  image.c 
    /php4/ext/standard/tests/image      image_type_to_mime_type.phpt 
  Log:
  fix jp2 detection and add testfile
  
Index: php4/ext/standard/image.c
diff -u php4/ext/standard/image.c:1.83 php4/ext/standard/image.c:1.84
--- php4/ext/standard/image.c:1.83      Thu Jan 16 14:45:26 2003
+++ php4/ext/standard/image.c   Fri Jan 17 13:51:30 2003
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: image.c,v 1.83 2003/01/16 19:45:26 helly Exp $ */
+/* $Id: image.c,v 1.84 2003/01/17 18:51:30 helly Exp $ */
 
 #include "php.h"
 #include <stdio.h>
@@ -623,7 +623,7 @@
 
        result->channels = php_read2(stream TSRMLS_CC); /* Csiz */
 
-       /* Collect and average bit depth info */
+       /* Collect bit depth info */
        highest_bit_depth = bit_depth = 0;
        for (i = 0; i < result->channels; i++) {
                bit_depth = php_stream_getc(stream); /* Ssiz[i] */
@@ -665,11 +665,7 @@
                box_length = php_read4(stream TSRMLS_CC); /* LBox */
                /* TBox */
                if (php_stream_read(stream, (void *)&box_type, sizeof(box_type)) != 
sizeof(box_type)) {
-                       break;
-               }
-
-               /* Safe to use the 0 return for EOF as neither of these can be 0 */ 
-               if (box_length == 0 || box_type == 0) {
+                       /* Use this as a general "out of stream" error */
                        break;
                }
 
@@ -1073,9 +1069,6 @@
        if (!memcmp(filetype, php_sig_iff, 4)) {
                return IMAGE_FILETYPE_IFF;
        }
-       if (php_get_wbmp(stream, NULL, 1 TSRMLS_CC)) {
-               return IMAGE_FILETYPE_WBMP;
-       }
 
        if (php_stream_read(stream, filetype+4, 8) != 8) {
                php_error_docref(NULL TSRMLS_CC, E_WARNING, "Read error!");
@@ -1086,6 +1079,10 @@
                return IMAGE_FILETYPE_JP2;
        }
 
+/* AFTER ALL ABOVE FAILED */
+       if (php_get_wbmp(stream, NULL, 1 TSRMLS_CC)) {
+               return IMAGE_FILETYPE_WBMP;
+       }
        return IMAGE_FILETYPE_UNKNOWN;
 }
 /* }}} */
Index: php4/ext/standard/tests/image/image_type_to_mime_type.phpt
diff -u php4/ext/standard/tests/image/image_type_to_mime_type.phpt:1.4 
php4/ext/standard/tests/image/image_type_to_mime_type.phpt:1.5
--- php4/ext/standard/tests/image/image_type_to_mime_type.phpt:1.4      Thu Jan 16 
14:46:12 2003
+++ php4/ext/standard/tests/image/image_type_to_mime_type.phpt  Fri Jan 17 13:51:30 
+2003
@@ -25,9 +25,11 @@
        var_dump($result);
 ?>
 --EXPECT--
-array(10) {
+array(11) {
   ["test1pix.bmp"]=>
   string(9) "image/bmp"
+  ["test1pix.jp2"]=>
+  string(9) "image/jp2"
   ["test1pix.jpc"]=>
   string(24) "application/octet-stream"
   ["test1pix.jpg"]=>

Index: php4/ext/standard/tests/image/test1pix.jp2
+++ php4/ext/standard/tests/image/test1pix.jp2
jP  

ftypjp2 jp2 
-jp2hihdrcolrjp2cOQ/R
\#"wwwvoongLgLgdPPPEWWWadKakadu-3.0.7
$


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

Reply via email to