9.4.0 (2023-01-02)¶
Security¶
Fix memory DOS in ImageFont¶
A corrupt or specially crafted TTF font could have font metrics that lead to
unreasonably large sizes when rendering text in font. ImageFont.py did not
check the image size before allocating memory for it. This dates to the PIL
fork. Pillow 8.2.0 added a check for large sizes, but did not consider the
case where one dimension is zero.
Null pointer dereference crash in ImageFont¶
Pillow attempted to dereference a null pointer in ImageFont, leading to a
crash. An error is now raised instead. This has been present since
Pillow 8.0.0.
API additions¶
Added start position for getmask and getmask2¶
Text may render differently when starting at fractional coordinates, so
FreeTypeFont.getmask() and FreeTypeFont.getmask2() now
support a start argument. This tuple of horizontal and vertical offset
will be used internally by ImageDraw.text() to more accurately place
text at the xy coordinates.
Added the exact encoding option for WebP¶
The exact encoding option for WebP is now supported. The WebP encoder
removes the hidden RGB values for better compression by default in libwebp 0.5
or later. By setting this option to True, the encoder will keep the hidden
RGB values.
Added signed option when saving JPEG2000¶
If the signed keyword argument is present and true when saving JPEG2000
images, then tell the encoder to save the image as signed.
getxmp()¶
XMP data can now be
decoded for WEBP images through getxmp().
Writing JPEG comments¶
When saving a JPEG image, a comment can now be written from
info, or by using an argument when saving:
im.save(out, comment="Test comment")
Other changes¶
Added support for DDS L and LA images¶
Support has been added to read and write L and LA DDS images in the uncompressed format, known as “luminance” textures.
Constants¶
In Pillow 9.1.0, the following constants were deprecated. That has been reversed and these constants will now remain available.
Image.NONEImage.NEARESTImage.ORDEREDImage.RASTERIZEImage.FLOYDSTEINBERGImage.WEBImage.ADAPTIVEImage.AFFINEImage.EXTENTImage.PERSPECTIVEImage.QUADImage.MESHImage.FLIP_LEFT_RIGHTImage.FLIP_TOP_BOTTOMImage.ROTATE_90Image.ROTATE_180Image.ROTATE_270Image.TRANSPOSEImage.TRANSVERSEImage.BOXImage.BILINEARImage.HAMMINGImage.BICUBICImage.LANCZOSImage.MEDIANCUTImage.MAXCOVERAGEImage.FASTOCTREEImage.LIBIMAGEQUANT