Pillow (and PIL) is currently able to open 8 bit per channel multi-channel images (such as RGB) but is able to open higher bit depth images (e.g. I16, I32, or Float32 images) if they are single channel (e.g., grayscale).
Previous ReferencesThis has been requested many times: #1828, #1885, #1839, #1602, and farther back.
RequirementsThe rough sequence for image loading is:
Image file is opened
Each of the ImagePlugin _accept functions have a chance to look at the first few bytes to determine if they should attempt to open the file
The *ImagePlugin._open
method is called giving the image plugin a chance to read more of the image and determine if it still wants to consider it a valid image of it's particular type. If it does, it passes back a tile definition which includes a decoder and an image size.
If there is a successful _open call, at some point later *ImagePlugin._load
may be called on the image, which runs the decoder producing a set of bytes in a raw mode. This is where things like compression are handled, but the output of the decoder is not necessarily what we're storing in our internal structures.
The image is unpacked (Unpack.c
) from the raw mode (e.g. I16;BS
) into a storage (Storage.c
) mode (I
).
It's now possible to operate on the image (e.g. crop, pixel access, etc)
There are 3 (or 4) image data pointers, as defined in Imaging.h:
struct ImagingMemoryInstance {
/* Format */
char mode[IMAGING_MODE_LENGTH]; /* Band names ("1", "L", "P", "RGB", "RGBA", "CMYK", "YCbCr", "BGR;xy") */
int type; /* Data type (IMAGING_TYPE_*) */
int depth; /* Depth (ignored in this version) */
int bands; /* Number of bands (1, 2, 3, or 4) */
int xsize; /* Image dimension. */
int ysize;
/* Colour palette (for "P" images only) */
ImagingPalette palette;
/* Data pointers */
UINT8 **image8; /* Set for 8-bit images (pixelsize=1). */
INT32 **image32; /* Set for 32-bit images (pixelsize=4). */
/* Internals */
char **image; /* Actual raster data. */
char *block; /* Set if data is allocated in a single block. */
int pixelsize; /* Size of a pixel, in bytes (1, 2 or 4) */
int linesize; /* Size of a line, in bytes (xsize * pixelsize) */
/* Virtual methods */
void (*destroy)(Imaging im);
};
The only one that is guaranteed to be set is **image
, which is an array of pointers to row data.
**image
pointer can be used for any width of pixel.**image32
pointer.IMAGING_TYPE_INT32
and IMAGING_TYPE_FLOAT32
imply 1 band. This will change.IMAGING_TYPE_INT16
Storage.c
, Unpack.c
, Pack.c
, Access.c
, PyAccess.py
, and Convert.c
We need a better definition of the format requirements. What are the various types of images that are used in GIS, Medical, or other fields that we'd want to interpret? We need small, redistributable versions of images that we can test against.
[in progress]
timo-piirmann, kkopachev, homm, twmr, MattKleinsmith and 33 more
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4