Hi! I have a bitmap file written by new versions of windows. These files seem to have the BITMAPV5HEADER header, as documented in this wikipedia article...
http://en.wikipedia.org/wiki/BMP_file_format The image metadata is as follows... -- sh:~/home/user$ identify -verbose badbmp.bmpImage: badbmp.bmp Format: BMP (Microsoft Windows bitmap image) Class: DirectClass Geometry: 940x705+0+0 Units: PixelsPerCentimeter Type: TrueColorMatte Endianess: Undefined Colorspace: RGB Depth: 8-bit Channel depth: red: 8-bit green: 8-bit blue: 8-bit alpha: 1-bit Channel statistics: Red: min: 7 (0.027451) max: 255 (1) mean: 82.3111 (0.322788) standard deviation: 42.3517 (0.166085) kurtosis: 9.21784 skewness: 2.94025 Green: min: 7 (0.027451) max: 255 (1) mean: 80.6959 (0.316454) standard deviation: 43.208 (0.169443) kurtosis: 8.72161 skewness: 2.84078 Blue: min: 5 (0.0196078) max: 255 (1) mean: 76.912 (0.301616) standard deviation: 45.1296 (0.176979) kurtosis: 7.82117 skewness: 2.6619 Alpha: min: 255 (1) max: 255 (1) mean: 255 (1) standard deviation: 0 (0) kurtosis: 0 skewness: 0 Image statistics: Overall: min: 5 (0.0196078) max: 255 (1) mean: 123.73 (0.485215) standard deviation: 84.6884 (0.332111) kurtosis: -1.16829 skewness: 0.805031 Alpha: rgba(52,52,52,0) #34343400 Rendering intent: Undefined Chromaticity: red primary: (-nan,-nan) green primary: (-nan,-nan) blue primary: (-nan,-nan) white point: (0,0) Interlace: None Background color: white Border color: rgba(223,223,223,1) Matte color: grey74 Transparent color: none Compose: Over Page geometry: 940x705+0+0 Dispose: Undefined Iterations: 0 Compression: Undefined Orientation: Undefined Properties: date:create: 2013-05-29T13:41:17-07:00 date:modify: 2013-05-29T13:41:17-07:00 signature: 06a0f3720396f746fa94ee4918f3150c9bd4931ff21e9bed66d8202b4824e215 Artifacts: verbose: true Tainted: False Filesize: 2.651MB Number pixels: 663KB Pixels per second: 66.27MB User time: 0.010u Elapsed time: 0:01.010 Version: ImageMagick 6.6.0-4 2012-08-17 Q16 http://www.imagemagick.org -- My code: -- imageBytes = Nonewith open(fileName, 'rb') as f: imageBytes = f.read() rawImage = Image.open(StringIO.StringIO(imageBytes)) -- This is what I get when I run it... File "/home/user/__init__.py", line 149, in convert_file_adv rawImage = Image.open(StringIO.StringIO(imageBytes)) File "/usr/lib/python2.7/dist-packages/PIL/Image.py", line 1965, in open return factory(fp, filename) File "/usr/lib/python2.7/dist-packages/PIL/ImageFile.py", line 91, in __init__ self._open() File "/usr/lib/python2.7/dist-packages/PIL/BmpImagePlugin.py", line 170, in _open self._bitmap(offset=offset) File "/usr/lib/python2.7/dist-packages/PIL/BmpImagePlugin.py", line 102, in _bitmap raise IOError("Unsupported BMP header type (%d)" % len(s))IOError: Unsupported BMP header type (124) -- Can someone tell how to get PIL to read these files? FYI I am using PIL==1.1.7 on linux. A lot of our customers have these files, so I have to find a workaround for them. Thanks, feroze.
_______________________________________________ Image-SIG maillist - Image-SIG@python.org http://mail.python.org/mailman/listinfo/image-sig