From: willertan1980 at yahoo dot com Operating system: WinXP sp1 PHP version: 4.3.1 PHP Bug Type: GetImageSize related Bug description: getimagesize () return incorrect values on bitmap (os2) files
Description: ------------ getimagesize () return incorrect values on bitmap files SYSTEM PHP 4.3.1(bundled version gd >1.6) , WinXP IIS 5.1 server, Intel P4 CPU TESTED image : RGB 24bits OS/2 bitmap (BM) generated by Photoshop 7.0 >>HEX DUMP image data 1st 32bytes - bitmaps header 12 bytes 4d 2c d0 01 00 00 00 00 00 1a 00 00 00 0c 00 00 f0 00 a5 00 01 00 18 00 b0 7f 6d a9 75 62 i realized that getimagesize () read OS/2 1.x bitmap by using Windows 3.x / OS/2 2.x structure, that is the reason the output was incorrect. >>DUMP form getimagesize () : Array ( [0] => 10813680 [1] => 1572865 [2] => 6 [3] => width="10813680" height="1572865" [bits] => 43373 [mime] => image/bmp ) >>DUMP from my own function, bmp_info () (identical to values that given by WinXP properties and photoshop 7) Array ( [width] => 240 [height] => 165 [planes] => 1 [bits] => 24 [bi_type] => Bitmap [bi_hsz] => 12 [bi_htype] => OS/2 1.x [ncolor] => 16777216 [xdensity] => 96 [ydensity] => 96 [density_mod] => 1 [component] => 3 [compression] => 0 ) >>Header for bmp >= Windows 2.x and OS/2 1.x typedef struct _WinBMPFileHeader, 14 bytes { WORD FileType; DWORD FileSize; WORD Reserved1; WORD Reserved2; DWORD BitmapOffset; } WINBMPFILEHEADER; Bitmap Windows 3.x should use this format, always 40 bytes typedef struct tagBITMAPINFOHEADER{ DWORD biSize; LONG biWidth; LONG biHeight; WORD biPlanes; WORD biBitCount; DWORD biCompression; DWORD biSizeImage; LONG biXPelsPerMeter; LONG biYPelsPerMeter; DWORD biClrUsed; DWORD biClrImportant; } BITMAPINFOHEADER, *PBITMAPINFOHEADER; but Bitmap Windows 2.x and OS/2 1.x should read like this, and its always 12 bytes typedef struct _Win2xBitmapHeader { DWORD Size; SHORT Width; SHORT Height; WORD Planes; WORD BitsPerPixel; } WIN2XBITMAPHEADER; REFERENCE http://netghost.narod.ru/gff/graphics/summary/os2bmp.htm http://netghost.narod.ru/gff/graphics/summary/micbmp.htm Windows BITMAPINFO- http://msdn.microsoft.com/library/en-us/gdi/bitmaps_0zn6.asp?frame=true Windows BITMAPINFOHEADER- http://msdn.microsoft.com/library/en-us/gdi/bitmaps_1rw2.asp?frame=true http://www.fastgraph.com/help/bmp_header_format.html *please remove this message if outdated or solved -- Edit bug report at http://bugs.php.net/?id=25581&edit=1 -- Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=25581&r=trysnapshot4 Try a CVS snapshot (php5): http://bugs.php.net/fix.php?id=25581&r=trysnapshot5 Fixed in CVS: http://bugs.php.net/fix.php?id=25581&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=25581&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=25581&r=needtrace Try newer version: http://bugs.php.net/fix.php?id=25581&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=25581&r=support Expected behavior: http://bugs.php.net/fix.php?id=25581&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=25581&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=25581&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=25581&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=25581&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=25581&r=dst IIS Stability: http://bugs.php.net/fix.php?id=25581&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=25581&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=25581&r=float