|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2001-09-08 15:07 UTC] pulstar at mail dot com
GetImageSize() don't recognize the JPG image format generated by a software called Arles Image Web Page Creator. I make a test script, that you can see at the address below. There have also links to sample images, etc. http://www.dr-micro.net/files/gis.php The browser display the images normally. This program website is at http://www.digitaldutch.com PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Oct 24 04:00:01 2025 UTC |
Solution: Read additional bytes to resync on the marker sequence. If marker length is too short, nothing is lost. If too long, one marker will be missing. Besides that APPn in $info array will contain consistent entries and no bogus markers. Uhm, ... and if the JPEG format follows the spec and contains correct marker lengths, it will work also ;-) This patch against 4.1.1 might do the trick: --- ext/standard/image.c.orig Sat Aug 11 19:03:37 2001 +++ ext/standard/image.c Tue Jan 22 22:10:42 2002 @@ -253,12 +253,20 @@ /* {{{ php_next_marker */ -static unsigned int php_next_marker(int socketd, FILE *fp, int issock) +static unsigned int php_next_marker(int socketd, FILE *fp, int issock, int isfirst) /* get next marker byte from file */ { int c; - /* get marker byte, swallowing possible padding */ + if (!isfirst) { + /* swallow bytes resulting from short marker length */ + do { + if ((c = FP_FGETC(socketd, fp, issock)) == EOF) + return M_EOI; /* we hit EOF */ + } while (c != 0xff); + } + + /* get marker byte, swallowing possible 0xff padding */ do { if ((c = FP_FGETC(socketd, fp, issock)) == EOF) return M_EOI; /* we hit EOF */ @@ -320,12 +328,14 @@ static struct gfxinfo *php_handle_jpeg (int socketd, FILE *fp, int issock, pval *info) { struct gfxinfo *result = NULL; + int isfirst = 1; /* First marker after JPEG sig 'FF D8 FF' */ unsigned int marker; char tmp[2]; unsigned char a[4]; for (;;) { - marker = php_next_marker(socketd, fp, issock); + marker = php_next_marker(socketd, fp, issock, isfirst); + isfirst = 0; switch (marker) { case M_SOF0: case M_SOF1: