Skip to main content

Module image_export

Module image_export 

Source
Expand description

Image export for a user-facing tool: every image comes out right, or it is reported as skipped with the reason.

crate::images::encode_image_for_document was written for embedding in office packages and reads only the stream’s filter, first colour-space name and bit depth. That is not enough to produce a faithful picture, and three classes came out silently wrong (#616):

  • an /Indexed image at 8 bits per component was written as greyscale, so the palette indices came out as grey levels;
  • /SMask, /Mask and /Decode were ignored, so transparency was lost and inverted images stayed inverted;
  • an Adobe CMYK JPEG was passed through unchanged, which browsers show with inverted colours.

A download button that hands out a wrong picture is worse than one that says “this one we could not extract”. So export_images expands palettes (small and exact), and skips everything else it cannot reproduce faithfully, naming why in SkipReason – including CMYK and non-sRGB ICC images, whose colours would shift without a colour-managed conversion.

Structs§

ExportedImage
An image that was exported as a faithful PNG or JPEG.
ImageExport
The result of export_images.
SkippedImage
An image that was left out because it could not be exported faithfully.

Enums§

SkipReason
Why an image was skipped rather than exported.

Functions§

export_images
Export every image XObject on every page, each once, as PNG or JPEG.