Removed Deprecated Items¶
Several deprecated items have been removed.
Support for spaces in tiff kwargs in the parameters for ‘x resolution’, ‘y resolution’, ‘resolution unit’, and ‘date time’ has been removed. Underscores should be used instead.
PIL.ImageDraw.ImageDraw.setfonthave been removed.
Closing Files When Opening Images¶
The file handling when opening images has been overhauled. Previously, Pillow would attempt to close some, but not all image formats after loading the image data. Now, the following behavior is specified:
For images where an open file is passed in, it is the responsibility of the calling code to close the file.
For images where Pillow opens the file and the file is known to have only one frame, the file is closed after loading.
If the file has more than one frame, or if it can’t be determined, then the file is left open to permit seeking to subsequent frames. It will be closed, eventually, in the
If the image is memory mapped, then we can’t close the mapping to the underlying file until we are done with the image. The mapping will be closed in the
Changes to GIF Handling When Saving¶
PIL.GifImagePlugin code has been refactored to fix the flow when
saving images. There are two external changes that arise from this:
The image to be saved is no longer modified in place by any of the operations of the save function. Previously it was modified when optimizing the image palette.
This refactor fixed some bugs with palette handling when saving multiple frame GIFs.
New Method: Image.remap_palette¶
PIL.Image.Image.remap_palette() has been
added. This method was hoisted from the GifImagePlugin code used to
optimize the palette.
Added Decoder Registry and Support for Python Based Decoders¶
There is now a decoder registry similar to the image plugin registries. Image plugins can register a decoder, and it will be called when the decoding is requested. This allows for the creation of pure Python decoders. While the Python decoders will not be as fast as their C based counterparts, they may be easier and quicker to develop or safer to run.
Many tests have been added, including correctness tests for image formats that have been previously untested.
We are now running automated tests in Docker containers against more Linux versions than are provided on Travis CI, which is currently Ubuntu 14.04 x64. This Pillow release is tested on 64-bit Alpine, Arch, Ubuntu 12.04 and 16.04, and 32-bit Debian Stretch and Ubuntu 14.04. This also covers a wider range of dependency versions than are provided on Travis natively.