#19315 [NEW]: getimagesize results wrong sizes
| From: | alberty at neptunelabs dot de | Date: | Mon, 09 Sep 2002 13:11:52 +0000 |
| Subject: | #19315 [NEW]: getimagesize results wrong sizes | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-18778@lists.php.net to get a copy of this message | ||
From: alberty@neptunelabs.de
Operating system: i686-pc-linux-gnu
PHP version: 4CVS-2002-09-09
PHP Bug Type: GetImageSize related
Bug description: getimagesize results wrong sizes
Hi,
the new feature of getimagesize to results the size of compressed swf
files results in the most cases wrong results, because the current
function try to get only a part of the compressed file.
You can validate the problem with files in macromedias trial
version of flash, found in
X:\Program Files\Macromedia\Flash MX\Samples\SWF
(eg:360_degrees.swf,Clock.swf,Drawing.swf,Import_video.swf)
Regards,
Steve
here a possible working patch:
------------------------------
205,214c205,213
< 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);
---
> static struct gfxinfo *php_handle_swc(php_stream * stream TSRMLS_DC)
> {
> struct gfxinfo *result = NULL;
>
> long bits;
> unsigned long length;
> char *b;
> char *ccontents;
> int clen;
216,217c215,232
< result = (struct gfxinfo *) ecalloc (1, sizeof (struct gfxinfo));
< php_stream_seek(stream, 5, SEEK_CUR);
---
> result = (struct gfxinfo *) ecalloc (1, sizeof (struct gfxinfo));
>
> php_stream_seek(stream, 5, SEEK_CUR);
>
> if ((clen = php_stream_copy_to_mem(stream, &ccontents,
PHP_STREAM_COPY_ALL, 0)) > 0)
> {
> length=clen*2;
> b= ecalloc (1, length + 1);
> uncompress (b, &length, ccontents, clen);
>
> 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);
>
> }
219,220c234,236
< php_stream_read(stream, a, sizeof(a)); /* fread(a, sizeof(a), 1, fp);
*/
< uncompress (b, &len, a, sizeof(a));
---
> result->bits = 0;
> result->channels = 0;
> return result;
222,230d237
< 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);
< result->bits = 0;
< result->channels = 0;
< return result;
--
Edit bug report at http://bugs.php.net/?id=19315&edit=1
--
Try a CVS snapshot: http://bugs.php.net/fix.php?id=19315&r=trysnapshot
Fixed in CVS: http://bugs.php.net/fix.php?id=19315&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=19315&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=19315&r=needtrace
Try newer version: http://bugs.php.net/fix.php?id=19315&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=19315&r=support
Expected behavior: http://bugs.php.net/fix.php?id=19315&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=19315&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=19315&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=19315&r=globals