Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to read a true color GIF image #3473

Closed
tomtobback opened this issue Nov 21, 2018 · 6 comments
Closed

How to read a true color GIF image #3473

tomtobback opened this issue Nov 21, 2018 · 6 comments

Comments

@tomtobback
Copy link

What did you do?

i'm trying to read frames in an RGB GIF image (not standard 8 bit palette)

What did you expect to happen?

reading frames of a standard indexed GIF image returns the original colours, works fine

What actually happened?

with my RGB GIF file, the colours go to black and white only, and the image.mode reports 'P' even when i can see in gimp that the image is RGB (not indexed colours)

What are your OS, Python and Pillow versions?

  • OS: Ubuntu Xenial
  • Python: 2.7.12
  • Pillow: 5.3.0

the image i'm using is at https://drive.google.com/file/d/1WEp8cuXAY_rAOE5E3tHm5zOBfJdWLn67/view?usp=sharing
sorry i'm not familiar enough with python/pillow to troubleshoot this by myself; is there any way to handle this kind of image?

@radarhere radarhere added GIF and removed GIF labels Nov 21, 2018
@radarhere radarhere changed the title how to read a true color GIF image How to read a true color GIF image Nov 21, 2018
@radarhere
Copy link
Member

The documentation states that 'GIF files are always read as grayscale (L) or palette mode (P) images.'. So the mode difference isn't an unintended bug.

@dhsdshdhk
Copy link

Is there no way to read it RGB or RGBA?

@aclark4life aclark4life added this to Backlog in Pillow May 11, 2019
@aclark4life aclark4life moved this from Backlog to In progress in Pillow May 11, 2019
@radarhere
Copy link
Member

The linked image is no longer available.

@tomtobback
Copy link
Author

hi, sorry image uploaded just now to https://cassiopeia.hk/etc/rob64.gif

@radarhere
Copy link
Member

#5333 fixed the colours - the second frame is now correct.

Testing, I find that GIMP thinks that any GIF with one frame is 'Indexed', and any GIF with more than one frame is RGB. This is understandable. While a single frame of a GIF image can only have up to 256 colors, multiple GIF frames potentially means multiple palettes, and so more than 256 colors.

So I don't believe that your GIF is special in some way. Reading all of the colors from multiple frames in a GIF will, I think, ultimately involve changing the image mode to RGB (#3735). However, the image that you've supplied is now read correctly. Let us know if you have any further comments.

Pillow automation moved this from In progress to Closed Apr 10, 2021
@radarhere
Copy link
Member

If you would like the image to become RGB/RGBA, you can use the convert() method - https://pillow.readthedocs.io/en/stable/reference/Image.html#PIL.Image.Image.convert

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Pillow
  
Closed
Development

No branches or pull requests

3 participants