| Name | Modified | Size | Downloads / Week |
|---|---|---|---|
| Parent folder | |||
| README.md | 2026-07-10 | 5.2 kB | |
| v10.10.0 source code.tar.gz | 2026-07-10 | 4.9 MB | |
| v10.10.0 source code.zip | 2026-07-10 | 5.1 MB | |
| Totals: 3 Items | 10.0 MB | 0 | |
Behavior change
- {meth}
pikepdf.PdfImage.as_pil_imageand {meth}pikepdf.PdfImage.extract_tonow apply an image's soft mask (/SMask) or explicit/colour-key mask (/Mask) by default, returning an image with an alpha channel (LAorRGBA) and writing a transparency-capable format (.png). Previously the mask was silently ignored and the opaque base image was returned. Images without a mask are unaffected. Passapply_mask=Falseto recover the old behavior and obtain only the opaque base image.
New features
- Image masking is now honored when extracting images.
/SMasksoft masks,/Maskstencil (explicit) masks, and/Maskcolour-key masks are composited into an alpha channel. Soft-mask images whose resolution differs from the base image are resampled to match (ISO 32000-2 Β§8.9.6). - Added support for
/CalRGB,/CalGrayand/CalCMYKimages, which previously raisedNotImplementedError. The samples are decoded as their device equivalents, and for CalRGB/CalGray an ICC profile synthesized from the colour space'sWhitePoint/Gamma/Matrixis attached to the extracted image so the calibration is preserved for colour-managed consumers. - Added support for the
/Labcolour space, extracted as a PillowLABimage (saved as TIFF) with the PDFL*/a*/b*ranges remapped to Pillow's conventions. - Added support for 16-bit-per-component images. 16-bit grayscale is extracted
losslessly as Pillow
I;16; 16-bit RGB and CMYK are reduced to 8-bit (with a warning) because Pillow has no higher-bit-depth raw mode for them. - Extended colour-space handling to several cases that previously raised
NotImplementedError: ICCBased CMYK images and indexed images now produce the correct default/Decodearray, and inline images that name their colour space now resolve it from the in-scope/Resourceswhen obtained via {func}pikepdf.parse_content_stream. - JPEG (
/DCTDecode) images with a non-default/ColorTransform-- a YCCK CMYK or a non-YCbCr RGB JPEG -- are now decoded via Pillow (which honours the JPEG's own markers) and transcoded, instead of failing to extract. - Filter chains that wrap a single terminal image codec (
/DCTDecode,/CCITTFaxDecode,/JPXDecode,/JBIG2Decode) in any number of generalized/specialized filters (Flate, LZW, ASCII85/Hex, RunLength) are now peeled and extracted seamlessly. - Added {attr}
pikepdf.PdfImage.MAX_IMAGE_PIXELS, a settable class-level limit on the number of pixels pikepdf will decode from a single image. Until set, it defaults tomax(500_000_000, PIL.Image.MAX_IMAGE_PIXELS)-- a floor suited to high-DPI scanned PDFs -- and tracks Pillow's setting; once assigned it becomes independent of Pillow. Set it toNoneto disable the check. - {class}
pikepdf.Arraynow implements the standard Pythonlistinterface: slicing (includingdelon slices and slice assignment), and theclear(),count(),index(),insert(),pop(),remove(), andreverse()methods.
Limitations
/SMaskInData(alpha encoded inside a JPEG 2000 stream) is applied only when Pillow's JPEG 2000 decoder surfaces the alpha channel itself; a pre-multiplied (SMaskInData 2) result is not un-premultiplied. A/Matteentry on a soft mask is not undone (a warning is emitted). When an image has both an/SMaskand a/Mask, the soft mask takes precedence. Colour-key masking is applied only to 8-bitL/RGB/CMYKimages.- A filter chain containing two or more terminal image codecs (for example
[/DCTDecode /CCITTFaxDecode]) cannot be decoded by any reader and now raises {class}~pikepdf.exceptions.UnsupportedImageTypeErrorrather thanNotImplementedError.
Security
- Hardened image extraction against decompression-bomb (memory exhaustion)
attacks. A malicious PDF could declare an image with enormous
/Widthand/Heightso that {meth}pikepdf.PdfImage.as_pil_imageattempted to allocate many gigabytes before reading the (tiny) image stream. pikepdf now enforces a configurable pixel limit, {attr}pikepdf.PdfImage.MAX_IMAGE_PIXELS(analogous toPIL.Image.MAX_IMAGE_PIXELS), across every image-decode path -- including the 2/4-bit transcoding path, 1-bit and 8-bit images, and the Pillow-decoded JPEG/JPEG2000/CCITT path. Oversized images raise {exc}pikepdf.DecompressionBombErrorand borderline images emit {exc}pikepdf.DecompressionBombWarning(both subclass Pillow's equivalents). (#733)
Fixed
- A CCITT fax image preceded by a stripped simple filter (e.g.
[/FlateDecode /CCITTFaxDecode]) now builds its TIFF header from the/CCITTFaxDecodefilter's own/DecodeParmsrather than the leading filter's, which previously produced a corrupt extraction. - Corrected the documentation of {class}
pikepdf.StreamDecodeLevel: thespecializedandalllevels were each described with the other's behavior.