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 clipboard image corrupted when saved to png #1811
importsysfromPILimportImageFilefromPILimportImageGrab# #1810 workaroundImageFile.LOAD_TRUNCATED_IMAGES=Trueim=ImageGrab.grabclipboard()
ifimisNone:
sys.exit('Error: No image data in clipboard')
im.save('save.bmp', 'BMP')
im.save('save.png', 'PNG')
If you open the BMP with Pillow, and try to save it as a PNG, is the result the same as the original PNG? Quite possibly the answer is no, it's just that if the answer were yes, then sharing the BMP here would mean that testers on any platform could reproduce the issue.
It looks like the data that's in the alpha channel is not an alpha or transparency mask, it's likely some sort of active area mask, or highlighting, or something. In this case, it's coming up like this:
The reason that the BMP is ok is that it's loaded into pillow as RGB, so the funky mask is ignored. So, the BMP is probably broken, and the png is as well.
Activity
radarhere commentedon Apr 6, 2016
If you open the BMP with Pillow, and try to save it as a PNG, is the result the same as the original PNG? Quite possibly the answer is no, it's just that if the answer were yes, then sharing the BMP here would mean that testers on any platform could reproduce the issue.
wiredfool commentedon Apr 6, 2016
I think that this and #1810 are both the same as #1293, since there is an error in the interpretation of the BMP header in the DIB in memory.
The best debugging for it is going to be to get dumps of the raw data from the imageGrab function, as noted here: #1293 (comment)
hugovk commentedon Apr 6, 2016
PR #1813 is merged, so this should be fixed too.
wiredfool commentedon Apr 6, 2016
Please check the fix, there may be other stuff hiding in there
techtonik commentedon Apr 6, 2016
Are there any Windows builds that could be installed?
techtonik commentedon Apr 7, 2016
@wiredfool is it possible to release 3.2.1 with those fixes?
techtonik commentedon Apr 7, 2016
Saved .bmp looks fine, but .png now has a different transparency problem:
wiredfool commentedon Apr 7, 2016
Can you dump the raw bytes from within the ImageGrab.grabclipboard()? As well as what you're seeing from the BMP and the PNG?
techtonik commentedon Apr 7, 2016
Attach contains all three files 1811alphabugs.zip
wiredfool commentedon Apr 9, 2016
It looks like the data that's in the alpha channel is not an alpha or transparency mask, it's likely some sort of active area mask, or highlighting, or something. In this case, it's coming up like this:
techtonik commentedon Apr 16, 2016
This is how inactive window looks like:
So that mask are probably RGB pixels that are applied with addition or some other algorithm.
Another things that it is not clear why BMP is saved ok.
wiredfool commentedon Apr 19, 2016
The reason that the BMP is ok is that it's loaded into pillow as
RGB, so the funky mask is ignored. So, the BMP is probably broken, and the png is as well.wiredfool commentedon May 5, 2016
Fix merged in #1847
techtonik commentedon May 5, 2016
Need #1815 to be merged to be able to test this.
techtonik commentedon May 5, 2016
This hints that egg can be converted to wheel:
That works fine. Thanks.