Looking through PIL (and related to this question), where can I get a comprehensive list of Image modes? I see "RGB", "RGBX", my code has "BGRX" somehow even though it's not mentioned in the PIL docs that I can see. How can I see which is which, what PIL supports, and what proper modes to select when interacting with windows API calls, for example?
Basically I know very little about image modes and would like to learn more than just what letters to put in to make it magically work.
There are two distinct concepts in Pillow, with confusingly similar names:
"Modes"
These are listed at https://pillow.readthedocs.io/en/latest/handbook/concepts.html#modes.
Per those docs:
This kind of "mode" is what is exposed through an
Image
's.mode
attribute, can be changed through the.convert()
method, and can be passed to methods that take amode
parameter. They are not the same as "raw modes"."Raw modes"
These are used internally by the raw decoder, which converts uncompressed data from an image file into a format that a PIL
Image
object can understand. There are several times more "raw modes" than "modes", and they convey information about not only the type (colored or grayscale) and bit depth of pixels in an image, but also their layout in the file. For example, raw modeRGB;L
is documented as meaning "24-bit true colour, line interleaved (first all red pixels, the all green pixels, finally all blue pixels)."As noted in the docs linked above (and also in the old PIL documentation), a list of raw modes can be found in
Unpack.c
. You'll find the list near the end of the file.Unpack.c
from the current master branch of Pillow: https://github.com/python-pillow/Pillow/blob/master/src/libImaging/Unpack.cUnpack.c
from the final release of PIL: http://svn.effbot.org/public/tags/pil-1.1.7/libImaging/Unpack.c