4.1.0
Removed Deprecated Items
Several deprecated items have been removed.
- Support for spaces in tiff kwargs in the parameters for ‘x resolution’, ‘yresolution’, ‘resolution unit’, and ‘date time’ has beenremoved. Underscores should be used instead.
- The methods
PIL.ImageDraw.ImageDraw.setink()
,PIL.ImageDraw.ImageDraw.setfill()
, andPIL.ImageDraw.ImageDraw.setfont()
have 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 formatsafter loading the image data. Now, the following behavioris specified:
- For images where an open file is passed in, it is theresponsibility of the calling code to close the file.
- For images where Pillow opens the file and the file is known to haveonly 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 subsequentframes. It will be closed, eventually, in the
close
ordel
methods. - If the image is memory mapped, then we can’t close the mapping tothe underlying file until we are done with the image. The mappingwill be closed in the
close
ordel
method.
Changes to GIF Handling When Saving
The PIL.GifImagePlugin
code has been refactored to fix the flow whensaving images. There are two external changes that arise from this:
- An
PIL.ImagePalette.ImagePalette
object is now acceptedas a specified palette argument inPIL.Image.Image.save()
. - The image to be saved is no longer modified in place by any of theoperations of the save function. Previously it was modified whenoptimizing the image palette.
This refactor fixed some bugs with palette handling when savingmultiple frame GIFs.
New Method: Image.remap_palette
The method PIL.Image.Image.remap_palette()
has beenadded. This method was hoisted from the GifImagePlugin code used tooptimize the palette.
Added Decoder Registry and Support for Python Based Decoders
There is now a decoder registry similar to the image pluginregistries. Image plugins can register a decoder, and it will becalled when the decoding is requested. This allows for the creation ofpure Python decoders. While the Python decoders will not be as fast astheir C based counterparts, they may be easier and quicker to developor safer to run.
Tests
Many tests have been added, including correctness tests for imageformats that have been previously untested.
We are now running automated tests in Docker containers against moreLinux versions than are provided on Travis CI, which is currentlyUbuntu 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 Ubuntu14.04. This also covers a wider range of dependency versions than areprovided on Travis natively.