Upgrading pillow 7 to 8
Breaking7.2.0 → 8.4.0Breaking11Security23Deprecated5New32Changed49Fixed32Other175
SecurityCVE-2021-23437 Raise ValueError if color specifier is too long [hugovk, radarhere].GHSA-98vv-pw6r-q6q4 · CVE-2021-23437 ↗
BreakingUpgrade verdict
11 breaking changes and 22 security fixes.
In plain terms
- Remove raqm.cmake [@nulano].
- Removed DPI rounding from BMP, JPEG and PNG loading [@radarhere].
- Removed WMF DPI rounding [@radarhere].
- Remove spikes when drawing thin pieslices [@xtsm].
Must act Top 5 of 38 that need code or config changes
Python requirement changed in 8.0.0: >=3.5 → >=3.6.
What you must change
Breaking11
Remove raqm.cmake [@nulano].
Removed DPI rounding from BMP, JPEG and PNG loading [@radarhere].
Removed WMF DPI rounding [@radarhere].
Remove spikes when drawing thin pieslices [@xtsm].
Removed TIFF DPI rounding [@radarhere].
Remove redundant check (addition to ) [@kkopachev].
Removed Image._MODEINFO [@radarhere].
Removed build_distance_tables return value [@radarhere].
Removed unused variable [@radarhere].
Remove duplicate code [@cgohlke].
Removed unused fromstring and tostring C methods [@radarhere].
Security22
CVE-2021-23437 Raise ValueError if color specifier is too long [hugovk, radarhere].
Fix 6-byte OOB read in FliDecode [wiredfool].
Add test for CVE-2021-25292 ReDoS [@hugovk].
Pillow through 8.2.0 and PIL (aka Python Imaging Library) through 1.1.7 allow an attacker to pass controlled parameters directly into a convert function to trigger a buffer overflow in Convert.c.
An issue was discovered in Pillow before 8.2.0. For BLP data, BlpImagePlugin did not properly check that reads (after jumping to file offsets) returned data. This could lead to a DoS where the decoder could be run a large number of times on empty data.
An issue was discovered in Pillow before 8.2.0. There is an out-of-bounds read in J2kDecode, in j2ku_graya_la.
An issue was discovered in Pillow before 8.2.0. PSDImagePlugin.PsdImageFile lacked a sanity check on the number of input layers relative to the size of the data block. This could lead to a DoS on Image.open prior to Image.load.
An issue was discovered in Pillow before 8.2.0. There is an out-of-bounds read in J2kDecode, in j2ku_gray_i.
An issue was discovered in Pillow before 8.2.0. For EPS data, the readline implementation used in EPSImageFile has to deal with any combination of \r and \n as line endings. It used an accidentally quadratic method of accumulating lines while looking for a line ending. A malicious EPS file could use this to perform a DoS of Pillow in the open phase, before an image was accepted for opening.
An issue was discovered in Pillow before 8.2.0. For FLI data, FliDecode did not properly check that the block advance was non-zero, potentially leading to an infinite loop on load.
Uncontrolled Resource Consumption in pillow
ModeratePillow before 8.1.1 allows attackers to cause a denial of service (memory consumption) because the reported size of a contained image is not properly checked for an ICNS container, and thus an attempted memory allocation can be very large.
An issue was discovered in Pillow before 8.1.1. TiffDecode has a heap-based buffer overflow when decoding crafted YCbCr files because of certain interpretation conflicts with LibTIFF in RGBA mode. NOTE: this issue exists because of an incomplete fix for CVE-2020-35654.
An issue was discovered in Pillow before 8.1.1. In TiffDecode.c, there is a negative-offset memcpy with an invalid size.
Pillow before 8.1.1 allows attackers to cause a denial of service (memory consumption) because the reported size of a contained image is not properly checked for an ICO container, and thus an attempted memory allocation can be very large.
An issue was discovered in Pillow before 8.1.1. The PDF parser allows a regular expression DoS (ReDoS) attack via a crafted PDF file because of a catastrophic backtracking regex.
Pillow before 8.1.1 allows attackers to cause a denial of service (memory consumption) because the reported size of a contained image is not properly checked for a BLP container, and thus an attempted memory allocation can be very large.
An issue was discovered in Pillow before 8.1.1. In TiffDecode.c, there is an out-of-bounds read in TiffreadRGBATile via invalid tile boundaries.
An issue was discovered in Pillow before 8.1.1. There is an out-of-bounds read in SGIRleDecode.c.
In Pillow before 8.1.0, PcxDecode has a buffer over-read when decoding a crafted PCX file because the user-supplied stride value is trusted for buffer calculations.
In Pillow before 8.1.0, SGIRleDecode has a 4-byte buffer over-read when decoding crafted SGI RLE image files because offsets and length tables are mishandled.
In Pillow before 8.1.0, TiffDecode has a heap-based buffer overflow when decoding crafted YCbCr files because of certain interpretation conflicts with LibTIFF in RGBA mode.
Deprecations to plan for
Deprecated5
De-zigzag JPEG's DQT when loading; deprecate convert_dict_qtables [@gofr].
Deprecated categories [@radarhere].
Makefile updates [@wiredfool].
Deprecate FreeType 2.7 [@hugovk].
Document when deprecations will be removed [@hugovk].
API changes
Generated by DepDelta from published Python source. Not mixed with prose notes.
- added:
variable DXGI_FORMAT_BC5_SNORM - added:
variable DXGI_FORMAT_BC5_TYPELESS - added:
variable DXGI_FORMAT_BC5_UNORM - added:
variable DXGI_FORMAT_R8G8B8A8_TYPELESS - added:
variable DXGI_FORMAT_R8G8B8A8_UNORM - added:
variable DXGI_FORMAT_R8G8B8A8_UNORM_SRGB
- changed:
function Ghostscript(tile, size, fp, scale=…) → function Ghostscript(tile, size, fp, scale=…, transparency=…) - changed:
method EpsImageFile.load(scale=…) → method EpsImageFile.load(scale=…, transparency=…)
- removed:
method GifImageFile.load_end() - added:
method GifImageFile.load_prepare()
- added:
variable MAGIC
- removed:
function fromstring(*args, **kw) - removed:
method Image.fromstring(*args, **kw) - removed:
method Image.offset(xoffset, yoffset=…) - removed:
method Image.tostring(*args, **kw) - changed:
function open(fp, mode=…) → function open(fp, mode=…, formats=…) - added:
method Exif.load_from_fp(fp, offset=…) - added:
variable ElementTree
- changed:
method ImageDraw.multiline_text(xy, text, fill=…, font=…, anchor=…, spacing=…, align=…, direction=…, features=…, language=…, stroke_width=…, stroke_fill=…) → method ImageDraw.multiline_text(xy, text, fill=…, font=…, anchor=…, spacing=…, align=…, direction=…, features=…, language=…, stroke_width=…, stroke_fill=…, embedded_color=…) - changed:
method ImageDraw.text(xy, text, fill=…, font=…, anchor=…, spacing=…, align=…, direction=…, features=…, language=…, stroke_width=…, stroke_fill=…, *args, **kwargs) → method ImageDraw.text(xy, text, fill=…, font=…, anchor=…, spacing=…, align=…, direction=…, features=…, language=…, stroke_width=…, stroke_fill=…, embedded_color=…, *args, **kwargs) - added:
method ImageDraw.multiline_textbbox(xy, text, font=…, anchor=…, spacing=…, align=…, direction=…, features=…, language=…, stroke_width=…, embedded_color=…) - added:
method ImageDraw.regular_polygon(bounding_circle, n_sides, rotation=…, fill=…, outline=…) - added:
method ImageDraw.rounded_rectangle(xy, radius=…, fill=…, outline=…, width=…) - added:
method ImageDraw.textbbox(xy, text, font=…, anchor=…, spacing=…, align=…, direction=…, features=…, language=…, stroke_width=…, embedded_color=…) - added:
method ImageDraw.textlength(text, font=…, direction=…, features=…, language=…, embedded_color=…)
- removed:
variable numpy
- changed:
method FreeTypeFont.getmask(text, mode=…, direction=…, features=…, language=…, stroke_width=…) → method FreeTypeFont.getmask(text, mode=…, direction=…, features=…, language=…, stroke_width=…, anchor=…, ink=…) - changed:
method FreeTypeFont.getmask2(text, mode=…, fill=…, direction=…, features=…, language=…, stroke_width=…, *args, **kwargs) → method FreeTypeFont.getmask2(text, mode=…, fill=…, direction=…, features=…, language=…, stroke_width=…, anchor=…, ink=…, *args, **kwargs) - added:
method FreeTypeFont.getbbox(text, mode=…, direction=…, features=…, language=…, stroke_width=…, anchor=…) - added:
method FreeTypeFont.getlength(text, mode=…, direction=…, features=…, language=…)
- changed:
function autocontrast(image, cutoff=…, ignore=…) → function autocontrast(image, cutoff=…, ignore=…, mask=…, preserve_tone=…) - added:
function contain(image, size, method=…)
- changed:
method ImagePalette.getcolor(color) → method ImagePalette.getcolor(color, image=…) - added:
property ImagePalette.palette
- added:
class GmDisplayViewer(UnixViewer) - added:
class IPythonViewer(Viewer) - added:
method GmDisplayViewer.get_command_ex(file, **options) - added:
method IPythonViewer.show_image(image, **options)
- added:
class BoxReader - added:
constructor BoxReader(fp, length=…) - added:
method BoxReader.has_next_box() - added:
method BoxReader.next_box_type() - added:
method BoxReader.read_boxes() - added:
method BoxReader.read_fields(field_format)
- added:
method JpegImageFile.getxmp()
- added:
field PdfParser.whitespace_optional_no_nl
- changed:
method PngInfo.add(cid, data) → method PngInfo.add(cid, data, after_idat=…) - added:
method PngImageFile.getxmp()
- changed:
constructor ImageFileDirectory_v2(ifh=…, prefix=…) → constructor ImageFileDirectory_v2(ifh=…, prefix=…, group=…) - added:
constructor TiffImageFile(fp=…, filename=…) - added:
field ImageFileDirectory_v1.tagtype: dict - added:
method TiffImageFile.getxmp() - added:
variable STRIP_SIZE - added:
variable SUBIFD - added:
variable YCBCRSUBSAMPLING
- changed:
function lookup(tag) → function lookup(tag, group=…) - added:
variable IFD - added:
variable TAGS_V2_GROUPS
- added:
class WalImageFile(ImageFile.ImageFile) - added:
field WalImageFile.format - added:
field WalImageFile.format_description - added:
method WalImageFile.load()