mirror of
https://github.com/storytold/pdfcraft.git
synced 2026-11-01 05:58:12 -06:00
Optimize decoded DCT images with the generic JPEG decoder, which converts three components from YCbCr to RGB whenever the JPEG itself doesn't say otherwise, and then dropped /DecodeParms. An RGB JPEG stored untransformed (/ColorTransform 0 and no Adobe marker) therefore came out in other colours when recompressed, resampled or merged from strips. The samples are now read with the colour transform ISO 32000-2 §7.4.8 gives them: an Adobe APP14 marker's flag, else /ColorTransform (default 1). Untransformed samples are taken as stored, and the result is written as a plain YCbCr JPEG (or Flate), which needs no /DecodeParms. When the marker and /ColorTransform disagree, a value is out of range, the parameters are not paired with the filter as §7.4 pairs them, or the decoder reads the components otherwise (named R, G and B), the image is left as it is. The tests draw each image with PdfCraft's renderer before and after Optimize: RGB JPEGs with and without an Adobe marker under each /ColorTransform, CMYK JPEGs (still left alone) and JPEG strips merged into one picture. Part of #1201.
26 lines
823 B
TOML
26 lines
823 B
TOML
[package]
|
|
name = "pdfcraft-optimize"
|
|
description = "The PDF Optimizer: image downsampling and recompression, discarding objects, clean-up"
|
|
version.workspace = true
|
|
edition.workspace = true
|
|
license.workspace = true
|
|
rust-version.workspace = true
|
|
repository.workspace = true
|
|
|
|
[lints]
|
|
workspace = true
|
|
|
|
[dependencies]
|
|
pdfcraft-cos = { workspace = true }
|
|
pdfcraft-content = { workspace = true }
|
|
pdfcraft-model = { workspace = true }
|
|
pdfcraft-annot = { workspace = true }
|
|
thiserror.workspace = true
|
|
# JPEG decoding (zune-jpeg) and encoding, and bicubic resampling; already in the tree.
|
|
image = { version = "0.25", default-features = false, features = ["jpeg"] }
|
|
# The same JPEG decoder, used directly to read samples untransformed (/ColorTransform 0).
|
|
zune-jpeg = "0.5"
|
|
|
|
[dev-dependencies]
|
|
pdfcraft-render = { workspace = true }
|