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
I have Windows 8 x64 system and installed Pillow version 2.8.2
I'm trying to grab image from clipboard. I press "Alt+PrtSc" and then call grabclipboard function, and get such error:
It'd be great to get this fixed for 2.9.0, due out on 1st July.
The good news is we now have a Windows-based CI to run unit tests, so if it's possible to simulate Alt+PrtSc (or just PrtSc, which also triggers it) on AppVeyor then this should definitely be unit-tested.
Unfortunately, the ImageGrab functions don't work on the windows CI, likely because there's something screwy with the graphics context on a headless vm.
That will return an image, but the resulting image is truncated. It can be shown or saved only if LOAD_TRUNCATED_IMAGES is true, but the image is one pixel shifted left and missing the top line.
This is because, for example, self.tile is: [('raw', (0, 0, 3360, 1050), 56L, ('BGRX', 13440, -1))]
instead of: [('raw', (0, 0, 3360, 1050), 52L, ('BGRX', 13440, -1))]
That third value in both cases is offset or self.fp.tell(), the problem with 2.8.0 is that an extra read had been made to load in a file_info['a_mask'], which doesn't make sense for this format, and putting the file pointer at the wrong place.
We should only be reading that alpha value when needed.
Ok I understand what is going on.
I rewrote part of the BMP loading process.
And I made sure it worked on supported bitmap files, fixed bogus behaviour from previous versions, but it did not have to work with unsupported files.
However @radarhere , the cause of the error you've been experiencing with this file may be... let's say, different.
Now I remember: the file rgb32bf.bmp is unsupported because it has a bitmask not supported by Pillow. Supported masks for 32-bit true color images have classic boundaries, with RGB channels in RGB or BGR order.
Here we have an esoteric RGB/A mask (the image is read correctly by XNView though), which has no matching dialect in PIL definitions for unpacking pixels.
Therefore I have been able to load this image, but with wrong colors (for instance, we have a problem with B and G channels)
I need to dig a bit more about the actual definition of what a DIB file is, and what the data in the spot that would normally be an alpha channel actually corresponds to. I think that the fix is actually correct for the RGB channels, for what that's worth.
Glad to hear that there are no external dependencies for BMP. I noticed the above problem because it seems that DIB is the internal bitmap representation for graphic shapes in OpenOffice (see XBitmap here).
Microsoft has an overview of DIBs here and a more historical piece here, and the actual “Bitmap Reference” is here. I hope this helps.
I've seen most of those links. What none of them are saying is the interpretation of the extra field of an RGBQuad, other than 'reserved'. There's possibly something newer that's done something documented with it, or we need to simply ignore it and just use the 'RGB' section of the image.
Activity
sallyruthstruik commentedon Jun 20, 2015
UPD It's version problem, when I installed Pillow version 2.6.0 everything worked ok
hugovk commentedon Jun 22, 2015
Reproducible with Pilllow 2.8.0, 2.8.1, 2.8.2.
Not reproducible with Pillow 2.6.0, 2.7.0.
hugovk commentedon Jun 22, 2015
Pillow 2.7.0 was released on 1st January this year, and 2.8.0 was released on 1st April.
PR #1125 may have caused it. Ping @artscoop.
It'd be great to get this fixed for 2.9.0, due out on 1st July.
The good news is we now have a Windows-based CI to run unit tests, so if it's possible to simulate Alt+PrtSc (or just PrtSc, which also triggers it) on AppVeyor then this should definitely be unit-tested.
radarhere commentedon Jun 22, 2015
Running OS X, I can reproduce the error using one of the files in the test suite - Tests/images/bmp/g/rgb32bf.bmp
Interestingly though, it's listed as unsupported.
wiredfool commentedon Jun 22, 2015
Unfortunately, the ImageGrab functions don't work on the windows CI, likely because there's something screwy with the graphics context on a headless vm.
hugovk commentedon Jun 25, 2015
Notes:
This can be partially fixed by adding this
elifnear here:That will return an image, but the resulting image is truncated. It can be shown or saved only if
LOAD_TRUNCATED_IMAGESis true, but the image is one pixel shifted left and missing the top line.This is because, for example,
self.tileis:[('raw', (0, 0, 3360, 1050), 56L, ('BGRX', 13440, -1))]instead of:
[('raw', (0, 0, 3360, 1050), 52L, ('BGRX', 13440, -1))]That third value in both cases is
offset or self.fp.tell(), the problem with 2.8.0 is that an extra read had been made to load in afile_info['a_mask'], which doesn't make sense for this format, and putting the file pointer at the wrong place.We should only be reading that alpha value when needed.
techtonik commentedon Nov 6, 2015
The regression appears with 3.0.0 too. 2.7.0 works ok.
techtonik commentedon Dec 15, 2015
So, any news on that?
artscoop commentedon Dec 30, 2015
Ok I understand what is going on.
I rewrote part of the BMP loading process.
And I made sure it worked on supported bitmap files, fixed bogus behaviour from previous versions, but it did not have to work with unsupported files.
However @radarhere , the cause of the error you've been experiencing with this file may be... let's say, different.
artscoop commentedon Dec 30, 2015
Now I remember: the file rgb32bf.bmp is unsupported because it has a bitmask not supported by Pillow. Supported masks for 32-bit true color images have classic boundaries, with RGB channels in RGB or BGR order.
Here we have an esoteric RGB/A mask (the image is read correctly by XNView though), which has no matching dialect in PIL definitions for unpacking pixels.
Therefore I have been able to load this image, but with wrong colors (for instance, we have a problem with B and G channels)
techtonik commentedon Apr 5, 2016
This bug can be closed. This works with 3.2.0:
techtonik commentedon Apr 5, 2016
It can be renamed "ImageGrab.grabclipboard() problem on Windows", because there are other issues there.
hugovk commentedon Apr 6, 2016
This bug is still present: I can reproduce it as described in the original report with Pillow 3.2.0 (Python 2.7, Windows 7).
34 remaining items
wiredfool commentedon Apr 14, 2016
I need to dig a bit more about the actual definition of what a DIB file is, and what the data in the spot that would normally be an alpha channel actually corresponds to. I think that the fix is actually correct for the
RGBchannels, for what that's worth.wiredfool commentedon Apr 14, 2016
BMP does not depend on any external library. (This particular version is essentially a header + raw image bytes)
jenstroeger commentedon Apr 14, 2016
Glad to hear that there are no external dependencies for BMP. I noticed the above problem because it seems that DIB is the internal bitmap representation for graphic shapes in OpenOffice (see XBitmap here).
Microsoft has an overview of DIBs here and a more historical piece here, and the actual “Bitmap Reference” is here. I hope this helps.
wiredfool commentedon Apr 15, 2016
I've seen most of those links. What none of them are saying is the interpretation of the extra field of an RGBQuad, other than 'reserved'. There's possibly something newer that's done something documented with it, or we need to simply ignore it and just use the 'RGB' section of the image.
techtonik commentedon Apr 16, 2016
@wiredfool lets close this ticket and move the discussion to #1811. Because saved .bmp is fine. There might be a bug in conversion routines.
wiredfool commentedon Apr 19, 2016
#1293 (comment)
techtonik commentedon Apr 19, 2016
@wiredfool "IOError: Unsupported BMP bitfields layout" problem is fixed, and it becomes hard to follow this ticket.
Fixes DIB image format
wiredfool commentedon Apr 19, 2016
Respinning this with #1847.
Fixes DIB image format
Fixes DIB image format