You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
3.2.0 DIB saving on Windows fails "image file is truncated" error #1810
#!/usr/bin/env pythonimportos, sysfromPILimportImageGrabim=ImageGrab.grabclipboard()
ifimisNone:
sys.exit('Error: No image data in clipboard')
im.show()
What did you expect to happen?
The image from clipboard is shown on the screen:
What actually happened?
Traceback (most recent call last):
File "savebmp.py", line 13, in <module>
im.show()
File "C:\Python27\lib\site-packages\PIL\Image.py", line 1730, in show
_show(self, title=title, command=command)
File "C:\Python27\lib\site-packages\PIL\Image.py", line 2480, in _show
_showxv(image, **options)
File "C:\Python27\lib\site-packages\PIL\Image.py", line 2485, in _showxv
ImageShow.show(image, title, **options)
File "C:\Python27\lib\site-packages\PIL\ImageShow.py", line 51, in show
if viewer.show(image, title=title, **options):
File "C:\Python27\lib\site-packages\PIL\ImageShow.py", line 75, in show
image = image.convert(base)
File "C:\Python27\lib\site-packages\PIL\Image.py", line 846, in convert
self.load()
File "C:\Python27\lib\site-packages\PIL\ImageFile.py", line 218, in load
"(%d bytes not processed)" % len(b))
IOError: image file is truncated (1312 bytes not processed)
Activity
hugovk commentedon Apr 6, 2016
With same Python/Pillow on Win7, I get a similar result when running the code as a script.
Edit: also get similar result in IDLE.
techtonik commentedon Apr 6, 2016
@hugovk
im == Nonecan only be shown in one case - when you don't have any data in clipboard. Otherwise you should get Traceback.hugovk commentedon Apr 6, 2016
@techtonik Yes, see my edit. (I'd run the test incorrectly.)
techtonik commentedon Apr 6, 2016
/cc @artscoop - do you know why it thinks the image file is truncated? Here is the image
__dict__:{ 'info': {'compression': 3, 'dpi': (0, 0)}, 'category': 0, 'palette': None, 'pyaccess': None, 'decoderconfig': (), 'filename': None, 'fp': < _io.BytesIO object at 0x023397E0 > , 'readonly': 1, 'im': None, 'mode': 'RGBA', 'decodermaxblock': 65536, 'tile': [ ('raw', (0, 0, 329, 423), 56L, ('BGRA', 1316, -1)), ], 'size': (329, 423), }hugovk commentedon Apr 6, 2016
PR #1813 is merged, so this should be fixed too.
techtonik commentedon Apr 7, 2016
In https://ci.appveyor.com/project/techtonik/pillow/build/3.3.pre.11/artifacts wheel I am not getting the
image file is truncatedmessage anymore.