PIL で開こうとしている BMP イメージがあります。ただし、PIL はこの画像を窒息させています...
有効なイメージです。画像のメタデータは次のとおりです。
sh:~/home/user$ identify -verbose badbmp.bmp
Image: 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
私のコードは次のようになります。
imageBytes = None
with open(fileName, 'rb') as f:
imageBytes = f.read()
rawImage = Image.open(StringIO.StringIO(imageBytes))
htis を実行しようとすると、次のようになります。
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)
この問題を回避または修正する方法を誰かが理解するのを手伝ってくれますか?