cvs: php4 /ext/standard image.c php_image.h
| From: | Derick Rethans | Date: | Thu, 23 May 2002 21:48:27 +0000 |
| Subject: | cvs: php4 /ext/standard image.c php_image.h | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-12065@lists.php.net to get a copy of this message | ||
derick Thu May 23 17:48:27 2002 EDT
Modified files:
/php4/ext/standard image.c php_image.h
Log:
- Added support for compressed SWF (Flash MX) files to getimagesize().
(Fixes feature request #17272).
@- Added support to getimagesize() for compressed Flash MX files. (Derick)
Index: php4/ext/standard/image.c
diff -u php4/ext/standard/image.c:1.55 php4/ext/standard/image.c:1.56
--- php4/ext/standard/image.c:1.55 Sat May 4 13:24:08 2002
+++ php4/ext/standard/image.c Thu May 23 17:48:27 2002
@@ -16,7 +16,7 @@
| Marcus Boerger <helly@php.net> |
+----------------------------------------------------------------------+
*/
-/* $Id: image.c,v 1.55 2002/05/04 17:24:08 sas Exp $ */
+/* $Id: image.c,v 1.56 2002/05/23 21:48:27 derick Exp $ */
/*
* Based on Daniel Schmitt's imageinfo.c which carried the following
* Copyright notice.
@@ -49,11 +49,16 @@
#endif
#include "php_image.h"
+#if HAVE_ZLIB
+#include "zlib.h"
+#endif
+
/* file type markers */
PHPAPI const char php_sig_gif[3] = {'G', 'I', 'F'};
PHPAPI const char php_sig_psd[4] = {'8', 'B', 'P', 'S'};
PHPAPI const char php_sig_bmp[2] = {'B', 'M'};
PHPAPI const char php_sig_swf[3] = {'F', 'W', 'S'};
+PHPAPI const char php_sig_swc[3] = {'C', 'W', 'S'};
PHPAPI const char php_sig_jpg[3] = {(char) 0xff, (char) 0xd8, (char) 0xff};
PHPAPI const char php_sig_png[8] = {(char) 0x89, (char) 0x50, (char) 0x4e, (char) 0x47,
(char) 0x0d, (char) 0x0a, (char) 0x1a, (char) 0x0a};
@@ -157,6 +162,37 @@
}
/* }}} */
+#if HAVE_ZLIB
+/* {{{ php_handle_swc
+ */
+static struct gfxinfo *php_handle_swc (php_stream * stream TSRMLS_DC)
+{
+ struct gfxinfo *result = NULL;
+
+ long bits;
+ unsigned char a[64];
+ unsigned long len = 64;
+ char *b;
+
+ b = ecalloc (1, len + 1);
+
+ result = (struct gfxinfo *) ecalloc (1, sizeof (struct gfxinfo));
+ php_stream_seek(stream, 5, SEEK_CUR);
+
+ php_stream_read(stream, a, sizeof(a)); /* fread(a, sizeof(a), 1, fp); */
+ uncompress (b, &len, a, sizeof(a));
+
+ bits = php_swf_get_bits (b, 0, 5);
+ result->width = (php_swf_get_bits (b, 5 + bits, bits) -
+ php_swf_get_bits (b, 5, bits)) / 20;
+ result->height = (php_swf_get_bits (b, 5 + (3 * bits), bits) -
+ php_swf_get_bits (b, 5 + (2 * bits), bits)) / 20;
+ efree (b);
+ return result;
+}
+/* }}} */
+#endif
+
/* {{{ php_handle_swf
*/
static struct gfxinfo *php_handle_swf (php_stream * stream TSRMLS_DC)
@@ -658,6 +694,10 @@
}
} else if (!memcmp(filetype, php_sig_swf, 3)) {
return IMAGE_FILETYPE_SWF;
+#if HAVE_ZLIB
+ } else if (!memcmp(filetype, php_sig_swc, 3)) {
+ return IMAGE_FILETYPE_SWC;
+#endif
} else if (!memcmp(filetype, php_sig_psd, 3)) {
return IMAGE_FILETYPE_PSD;
} else if (!memcmp(filetype, php_sig_bmp, 2)) {
@@ -739,6 +779,11 @@
case IMAGE_FILETYPE_SWF:
result = php_handle_swf(stream TSRMLS_CC);
break;
+#if HAVE_ZLIB
+ case IMAGE_FILETYPE_SWC:
+ result = php_handle_swc(stream TSRMLS_CC);
+ break;
+#endif
case IMAGE_FILETYPE_PSD:
result = php_handle_psd(stream TSRMLS_CC);
break;
Index: php4/ext/standard/php_image.h
diff -u php4/ext/standard/php_image.h:1.13 php4/ext/standard/php_image.h:1.14
--- php4/ext/standard/php_image.h:1.13 Mon Mar 18 13:54:28 2002
+++ php4/ext/standard/php_image.h Thu May 23 17:48:27 2002
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: php_image.h,v 1.13 2002/03/18 18:54:28 wez Exp $ */
+/* $Id: php_image.h,v 1.14 2002/05/23 21:48:27 derick Exp $ */
#ifndef PHP_IMAGE_H
#define PHP_IMAGE_H
@@ -41,7 +41,8 @@
IMAGE_FILETYPE_JPC,
IMAGE_FILETYPE_JP2,
IMAGE_FILETYPE_JPX,
- IMAGE_FILETYPE_JB2
+ IMAGE_FILETYPE_JB2,
+ IMAGE_FILETYPE_SWC
} image_filetype;
/* }}} */