Upgrading pillow 11 to 12
Breaking11.3.0 → 12.3.0Breaking3Security27Platform3Deprecated4New15Changed119Fixed110Other189
BreakingUpgrade verdict
3 breaking changes and 3 platform requirement changes and 27 security fixes.
In plain terms
- Pillow no longer works with very old versions of the FreeType font library.
- Code that used features marked deprecated in earlier versions must be updated.
- Some color-management modes that did not represent images are no longer available.
- Pillow 12 no longer runs on Python 3.9; you need a newer Python.
Must act Top 5 of 37 that need code or config changes
Python requirement changed in 12.0.0: >=3.9 → >=3.10.
What you must change
Breaking3
Removes support for FreeType 2.9.0 and earlier.
FreeTypeRemoves APIs deprecated for Pillow 12.0.0.
Removes non-image ImageCms modes.
ImageCmsSecurity27
Does not set eval() globals in ImageMath.unsafe_eval().
ImageMath.unsafe_eval()eval()Adds decompression bomb checks to FontFile classes.
FontFileAdds a decompression bomb check to GdImageFile.
GdImageFileApplies a libtiff patch to fix CVE-2026-4775.
libtiffFixes an unsafe pointer dereference from an unchecked Python integer in Tk initialization.
Removes or protects secrets in Actions.
Pillow is a Python imaging library. Prior to 12.3.0, WindowsViewer.get_command() constructed a cmd.exe shell command by directly embedding a file path into an f-string without escaping and passed the result to subprocess.Popen(..., shell=True), allowing shell metacharacters in the file path to inject arbitrary cmd.exe commands. This issue is fixed in version 12.3.0.
Medium · CVSS 4.5Pillow is a Python imaging library. Prior to 12.3.0, PIL/FontFile.py FontFile.compile() assembled per-glyph images into a combined bitmap with Image.new("1", (xsize, ysize)) without calling Image._decompression_bomb_check(), allowing a font to trigger excessive allocation during conversion or saving. This issue is fixed in version 12.3.0.
High · CVSS 7.5Pillow: Decompression Bomb DoS via PdfParser.PdfStream.decode()
High · CVSS 7.5Pillow is a Python imaging library. Prior to 12.3.0, PIL/BdfFontFile.py bdf_char() read the BBX width and height field from a BDF font file and passed attacker-controlled dimensions to Image.new() without calling Image._decompression_bomb_check(), bypassing Pillow's documented decompression bomb protection and allowing excessive memory allocation. This issue is fixed in version 12.3.0.
High · CVSS 7.5Pillow is a Python imaging library. Prior to 12.3.0, PIL/PcfFontFile.py _load_bitmaps() read glyph dimensions from the PCF METRICS section and passed them directly to Image.frombytes() without calling Image._decompression_bomb_check(), allowing crafted PCF font data to cause excessive memory allocation. This issue is fixed in version 12.3.0.
High · CVSS 7.5Pillow is a Python imaging library. Prior to 12.3.0, PIL/GdImageFile.py GdImageFile._open() read image dimensions from the GD 2.x header and stored them in self._size without calling Image._decompression_bomb_check(), allowing a crafted .gd file to trigger excessive C-heap allocation when loaded. This issue is fixed in version 12.3.0.
High · CVSS 7.5Pillow JPEG2000 tiled decode retains a growing scratch buffer and can be used for denial of service
Pillow is a Python imaging library. Prior to 12.3.0, Pillow's public rank-filter API can trigger a native heap out-of-bounds write when given a very large odd filter size because ImageFilter.RankFilter.filter() calls image.expand(size // 2, size // 2) before rank-filter size validation and ImagingExpand() computes output dimensions with unchecked signed int arithmetic. This issue is fixed in version 12.3.0.
High · CVSS 8.2Pillow TGA RLE encoder can serialize up to ~57 KB of adjacent heap data into generated images
Medium · CVSS 6.5Pillow is a Python imaging library. Prior to 12.3.0, Pillow public image coordinate APIs can trigger a native heap out-of-bounds write when given coordinates near the signed 32-bit integer limits in Image.paste(), Image.crop(), or Image.alpha_composite(). This issue is fixed in version 12.3.0.
High · CVSS 7.5Pillow: Out-of-bounds read via attacker-controlled row stride on Pillow's mmap path (McIdas AREA files)
Pillow is a Python imaging library. Prior to 12.3.0, Pillow's ImageCms.ImageCmsTransform.apply(im, imOut) API can trigger controlled native heap corruption when the caller supplies an output image whose mode does not match the transform's declared output mode. This issue is fixed in version 12.3.0.
High · CVSS 7.5Pillow is a Python imaging library. From 12.0.0 through 12.2.0, Pillow's EPS parser in PIL/EpsImagePlugin.py accepts a negative byte count in the %%BeginBinary directive, allowing a crafted EPS file to cause Image.open() to seek backwards to the same directive and parse it repeatedly in an infinite loop. This issue is fixed in version 12.3.0.
High · CVSS 7.5Pillow is a Python imaging library. From version 11.2.1 to before version 12.2.0, passing nested lists as coordinates to APIs that accept coordinates such as ImagePath.Path, ImageDraw.ImageDraw.polygon and ImageDraw.ImageDraw.line could cause a heap buffer overflow, as nested lists were recursively unpacked beyond the allocated buffer. Coordinate lists are now validated to contain exactly two numeric coordinates. This issue has been patched in version 12.2.0.
Medium · CVSS 5.5Pillow is a Python imaging library. Prior to version 12.2.0, if a font advances for each glyph by an exceeding large amount, when Pillow keeps track of the current position, it may lead to an integer overflow. This issue has been patched in version 12.2.0.
Medium · CVSS 5.5Pillow has a PDF Parsing Trailer Infinite Loop (DoS)
Medium · CVSS 5.5Pillow is a Python imaging library. From version 10.3.0 to before version 12.2.0, processing a malicious PSD file could lead to memory corruption, potentially resulting in a crash or arbitrary code execution. This issue has been patched in version 12.2.0.
High · CVSS 7.8Pillow is a Python imaging library. Versions 10.3.0 through 12.1.1 did not limit the amount of GZIP-compressed data read when decoding a FITS image, making them vulnerable to decompression bomb attacks. A specially crafted FITS file could cause unbounded memory consumption, leading to denial of service (OOM crash or severe performance degradation). If users are unable to immediately upgrade, they should only open specific image formats, excluding FITS, as a workaround.
High · CVSS 7.5Fixes an out-of-bounds write when decoding images with invalid tile extents.
Pillow is a Python imaging library. From 10.3.0 to before 12.1.1, an out-of-bounds write may be triggered when loading a specially crafted PSD image. This vulnerability is fixed in 12.1.1.
High · CVSS 7.5Limits the length of read operations in ImageFont._load_pilfont_data().
ImageFont._load_pilfont_data()Platform3
Drops support for Python 3.9.
Adds support for Python 3.14.
Adds support for Python 3.15.
Deprecations to plan for
Deprecated4
Deprecates getdata() in favour of the new get_flattened_data().
getdata()get_flattened_data()Deprecates Image._show.
Image._showDeprecates ImageCmsProfile product_name and product_info.
ImageCmsProfileproduct_nameproduct_infoDeprecates fromarray mode only when changing data types.
fromarrayAPI changes
Generated by DepDelta from published Python source. Not mixed with prose notes.
- changed:
method BmpRleDecoder.decode(buffer: bytes | Image.SupportsArrayInterface) -> tuple[int, int] → method BmpRleDecoder.decode(buffer: Image.DecoderInput) -> tuple[int, int]
- added:
method CurImageFile.load_end() -> None - added:
method CurImageFile.load_prepare() -> None
- changed:
method DdsRgbDecoder.decode(buffer: bytes | Image.SupportsArrayInterface) -> tuple[int, int] → method DdsRgbDecoder.decode(buffer: Image.DecoderInput) -> tuple[int, int]
- added:
field Base.FrameRate
- changed:
method FitsGzipDecoder.decode(buffer: bytes | Image.SupportsArrayInterface) -> tuple[int, int] → method FitsGzipDecoder.decode(buffer: Image.DecoderInput) -> tuple[int, int]
- added:
method FontFile.to_imagefont() -> ImageFont.ImageFont
- added:
variable TYPE_CHECKING
- added:
variable TYPE_CHECKING
- removed:
property IcnsImageFile.size -> tuple[int, int] | tuple[int, int, int] - added:
property IcnsImageFile.size -> tuple[int, int]
- removed:
function isImageType(t: Any) -> TypeGuard[Image] - removed:
variable core - changed:
function frombytes(mode: str, size: tuple[int, int], data: bytes | bytearray | SupportsArrayInterface, decoder_name: str=…, *args: Any) -> Image → function frombytes(mode: str, size: tuple[int, int], data: DecoderInput, decoder_name: str=…, *args: Any) -> Image - changed:
method Image.frombytes(data: bytes | bytearray | SupportsArrayInterface, decoder_name: str=…, *args: Any) -> None → method Image.frombytes(data: DecoderInput, decoder_name: str=…, *args: Any) -> None - changed:
method Image.putpixel(xy: tuple[int, int], value: float | tuple[int, ...] | list[int]) -> None → method Image.putpixel(xy: tuple[int, int] | list[int], value: float | tuple[int, ...] | list[int]) -> None - added:
method Image.get_flattened_data(band: int | None=…) -> tuple[tuple[int, ...], ...] | tuple[float, ...] - added:
variable DecoderInput
- removed:
function versions() -> tuple[str, str | None, str, str]
- changed:
field ImageDraw.font: ImageFont.ImageFont | ImageFont.FreeTypeFont | ImageFont.TransposedFont | None → field ImageDraw.font: ImageFont.BaseImageFont | None - changed:
function getdraw(im: Image.Image | None=…, hints: list[str] | None=…) -> tuple[ImageDraw2.Draw | None, ModuleType] → function getdraw(im: Image.Image | None=…) -> tuple[ImageDraw2.Draw | None, ModuleType] - changed:
method ImageDraw.getfont() -> ImageFont.ImageFont | ImageFont.FreeTypeFont | ImageFont.TransposedFont → method ImageDraw.getfont() -> ImageFont.BaseImageFont - changed:
method ImageDraw.multiline_text(xy: tuple[float, float], text: AnyStr, fill: _Ink | None=…, font: ImageFont.ImageFont | ImageFont.FreeTypeFont | ImageFont.TransposedFont | None=…, anchor: str | None=…, spacing: float=…, align: str=…, direction: str | None=…, features: list[str] | None=…, language: str | None=…, stroke_width: float=…, stroke_fill: _Ink | None=…, embedded_color: bool=…, *, font_siz… → method ImageDraw.multiline_text(xy: tuple[float, float], text: AnyStr, fill: _Ink | None=…, font: ImageFont.BaseImageFont | None=…, anchor: str | None=…, spacing: float=…, align: str=…, direction: str | None=…, features: list[str] | None=…, language: str | None=…, stroke_width: float=…, stroke_fill: _Ink | None=…, embedded_color: bool=…, *, font_size: float | None=…) -> None - changed:
method ImageDraw.multiline_textbbox(xy: tuple[float, float], text: AnyStr, font: ImageFont.ImageFont | ImageFont.FreeTypeFont | ImageFont.TransposedFont | None=…, anchor: str | None=…, spacing: float=…, align: str=…, direction: str | None=…, features: list[str] | None=…, language: str | None=…, stroke_width: float=…, embedded_color: bool=…, *, font_size: float | None=…) -> tuple[float, float, flo… → method ImageDraw.multiline_textbbox(xy: tuple[float, float], text: AnyStr, font: ImageFont.BaseImageFont | None=…, anchor: str | None=…, spacing: float=…, align: str=…, direction: str | None=…, features: list[str] | None=…, language: str | None=…, stroke_width: float=…, embedded_color: bool=…, *, font_size: float | None=…) -> tuple[float, float, float, float] - changed:
method ImageDraw.text(xy: tuple[float, float], text: AnyStr, fill: _Ink | None=…, font: ImageFont.ImageFont | ImageFont.FreeTypeFont | ImageFont.TransposedFont | None=…, anchor: str | None=…, spacing: float=…, align: str=…, direction: str | None=…, features: list[str] | None=…, language: str | None=…, stroke_width: float=…, stroke_fill: _Ink | None=…, embedded_color: bool=…, *args: Any, **kwargs:… → method ImageDraw.text(xy: tuple[float, float], text: AnyStr | ImageText.Text[AnyStr], fill: _Ink | None=…, font: ImageFont.BaseImageFont | None=…, anchor: str | None=…, spacing: float=…, align: str=…, direction: str | None=…, features: list[str] | None=…, language: str | None=…, stroke_width: float=…, stroke_fill: _Ink | None=…, embedded_color: bool=…, *args: Any, **kwargs: Any) -> None - changed:
method ImageDraw.textbbox(xy: tuple[float, float], text: AnyStr, font: ImageFont.ImageFont | ImageFont.FreeTypeFont | ImageFont.TransposedFont | None=…, anchor: str | None=…, spacing: float=…, align: str=…, direction: str | None=…, features: list[str] | None=…, language: str | None=…, stroke_width: float=…, embedded_color: bool=…, *, font_size: float | None=…) -> tuple[float, float, float, float] → method ImageDraw.textbbox(xy: tuple[float, float], text: AnyStr, font: ImageFont.BaseImageFont | None=…, anchor: str | None=…, spacing: float=…, align: str=…, direction: str | None=…, features: list[str] | None=…, language: str | None=…, stroke_width: float=…, embedded_color: bool=…, *, font_size: float | None=…) -> tuple[float, float, float, float] - changed:
method ImageDraw.textlength(text: AnyStr, font: ImageFont.ImageFont | ImageFont.FreeTypeFont | ImageFont.TransposedFont | None=…, direction: str | None=…, features: list[str] | None=…, language: str | None=…, embedded_color: bool=…, *, font_size: float | None=…) -> float → method ImageDraw.textlength(text: AnyStr, font: ImageFont.BaseImageFont | None=…, direction: str | None=…, features: list[str] | None=…, language: str | None=…, embedded_color: bool=…, *, font_size: float | None=…) -> float
- removed:
function raise_oserror(error: int) -> OSError - changed:
method PyDecoder.decode(buffer: bytes | Image.SupportsArrayInterface) -> tuple[int, int] → method PyDecoder.decode(buffer: Image.DecoderInput) -> tuple[int, int] - changed:
method PyDecoder.set_as_raw(data: bytes, rawmode: str | None=…, extra: tuple[Any, ...]=…) -> None → method PyDecoder.set_as_raw(data: bytes | bytearray, rawmode: str | None=…, extra: tuple[Any, ...]=…) -> None
- added:
field BuiltinFilter.name: str
- changed:
class FreeTypeFont → class FreeTypeFont(BaseImageFont) - changed:
class ImageFont → class ImageFont(BaseImageFont) - changed:
class TransposedFont → class TransposedFont(BaseImageFont) - changed:
method FreeTypeFont.getbbox(text: str | bytes, mode: str=…, direction: str | None=…, features: list[str] | None=…, language: str | None=…, stroke_width: float=…, anchor: str | None=…) -> tuple[float, float, float, float] → method FreeTypeFont.getbbox(text: str | bytes | bytearray, mode: str=…, direction: str | None=…, features: list[str] | None=…, language: str | None=…, stroke_width: float=…, anchor: str | None=…) -> tuple[float, float, float, float] - changed:
method TransposedFont.getbbox(text: str | bytes, *args: Any, **kwargs: Any) -> tuple[int, int, float, float] → method TransposedFont.getbbox(text: str | bytes | bytearray, *args: Any, **kwargs: Any) -> tuple[int, int, float, float] - added:
class BaseImageFont(abc.ABC) - added:
method BaseImageFont.getbbox(text: str | bytes | bytearray, *args: Any, **kwargs: Any) -> tuple[float, float, float, float] - added:
method BaseImageFont.getlength(text: str | bytes, *args: Any, **kwargs: Any) -> float - added:
method BaseImageFont.getmask(text: str | bytes, mode: str=…, *args: Any, **kwargs: Any) -> Image.core.ImagingCore
- changed:
function grab(bbox: tuple[int, int, int, int] | None=…, include_layered_windows: bool=…, all_screens: bool=…, xdisplay: str | None=…, window: int | ImageWin.HWND | None=…) -> Image.Image → function grab(bbox: tuple[int, int, int, int] | None=…, include_layered_windows: bool=…, all_screens: bool=…, xdisplay: str | None=…, window: int | ImageWin.HWND | None=…, *, scale_down: bool=…) -> Image.Image
- removed:
function eval(expression: str, _dict: dict[str, Any]=…, **kw: Any) -> Any - changed:
function lambda_eval(expression: Callable[[dict[str, Any]], Any], options: dict[str, Any]=…, **kw: Any) -> Any → function lambda_eval(expression: Callable[[dict[str, Any]], Any], **kw: Any) -> Any - changed:
function unsafe_eval(expression: str, options: dict[str, Any]=…, **kw: Any) -> Any → function unsafe_eval(expression: str, **kw: Any) -> Any - added:
variable TYPE_CHECKING
- changed:
method LutBuilder.build_default_lut() -> None → method LutBuilder.build_default_lut() -> bytearray
- removed:
variable QByteArray - removed:
variable QIODevice - removed:
variable QImage - removed:
variable QPixmap
- added:
variable TYPE_CHECKING
- added:
class Text(Generic[AnyStr]) - added:
constructor Text(text: AnyStr, font: ImageFont.BaseImageFont | None=…, mode: str=…, spacing: float=…, direction: str | None=…, features: list[str] | None=…, language: str | None=…) -> None - added:
method Text.embed_color() -> None - added:
method Text.get_bbox(xy: tuple[float, float]=…, anchor: str | None=…, align: str=…) -> tuple[float, float, float, float] - added:
method Text.get_length() -> float - added:
method Text.stroke(width: float=…, fill: _Ink | None=…) -> None - added:
method Text.wrap(width: int, height: int | None=…, scaling: str | tuple[str, int] | None=…) -> Text[AnyStr] | None
- changed:
method Dib.frombytes(buffer: bytes) -> None → method Dib.frombytes(buffer: bytes | memoryview) -> None
- removed:
function dump(c: Sequence[int | bytes]) -> None - removed:
function i(c: bytes) -> int
- added:
variable TYPE_CHECKING
- changed:
method MspDecoder.decode(buffer: bytes | Image.SupportsArrayInterface) -> tuple[int, int] → method MspDecoder.decode(buffer: Image.DecoderInput) -> tuple[int, int]
- added:
method PcdImageFile.load_prepare() -> None
- added:
variable TYPE_CHECKING
- changed:
method PdfParser.read_prev_trailer(xref_section_offset: int) -> None → method PdfParser.read_prev_trailer(xref_section_offset: int, processed_offsets: list[int] | None=…) -> None - changed:
method PdfStream.decode() -> bytes → method PdfStream.decode(max_length: int=…) -> bytes - changed:
static method PdfParser.get_literal_string(data: bytes | bytearray | mmap.mmap, offset: int) -> tuple[bytes, int] → static method PdfParser.get_literal_string(data: bytes | bytearray | memoryview | mmap.mmap, offset: int) -> tuple[bytes, int] - changed:
static method PdfParser.get_value(data: bytes | bytearray | mmap.mmap, offset: int, expect_indirect: IndirectReference | None=…, max_nesting: int=…) -> tuple[Any, int | None] → static method PdfParser.get_value(data: bytes | bytearray | memoryview | mmap.mmap, offset: int, expect_indirect: IndirectReference | None=…, max_nesting: int=…) -> tuple[Any, int | None]
- changed:
method PpmDecoder.decode(buffer: bytes | Image.SupportsArrayInterface) -> tuple[int, int] → method PpmDecoder.decode(buffer: Image.DecoderInput) -> tuple[int, int] - changed:
method PpmPlainDecoder.decode(buffer: bytes | Image.SupportsArrayInterface) -> tuple[int, int] → method PpmPlainDecoder.decode(buffer: Image.DecoderInput) -> tuple[int, int]
- changed:
method QoiDecoder.decode(buffer: bytes | Image.SupportsArrayInterface) -> tuple[int, int] → method QoiDecoder.decode(buffer: Image.DecoderInput) -> tuple[int, int]
- changed:
method SGI16Decoder.decode(buffer: bytes | Image.SupportsArrayInterface) -> tuple[int, int] → method SGI16Decoder.decode(buffer: Image.DecoderInput) -> tuple[int, int]
- added:
variable TYPE_CHECKING
- changed:
method XpmDecoder.decode(buffer: bytes | Image.SupportsArrayInterface) -> tuple[int, int] → method XpmDecoder.decode(buffer: Image.DecoderInput) -> tuple[int, int]
- changed:
variable features: dict[str, tuple[str, str | bool, str | None]] → variable features: dict[str, tuple[str, str, str | None]]