PdfCraft: An open-source PDF reader and editor written by scratch in pure Rust
M11: Export ▸ Images decodes CCITT fax images
Grzegorz Martens4712abaabb78
diff --git a/ROADMAP.md b/ROADMAP.mdindex 87f5b6705..9d6b7a43f 100644--- a/ROADMAP.md+++ b/ROADMAP.md@@ -205,6 +205,7 @@ Ranked; detail and the full milestone table in [docs/roadmap.md](docs/roadmap.md- **2026-10-24 (M3, window move on Wayland, #3970 follow-up):** After a move or resize by PdfCraft's own title bar or edges, the button release given back to egui goes before the pointer leaving the window, so hover no longer sticks at the old place until the pointer moves. Found by CodeRabbit in review of #3970; a unit test covers it. Estimates unchanged.- **2026-10-24 (M14, #4253):** The annotation quick bar remembers Keep tool selected across restarts, including unpinning. Old and malformed settings keep safe defaults; the opt-in UI control channel reads and changes the same preference. Estimates unchanged.+- **2026-10-24 (M11, black-and-white pictures):** A scan saved as a 1-bit PNG became an eight-bit grey image when made into a PDF, larger than the PNG; Create PDF now stores pictures of only black and white at one bit (Group 4 when smaller), the optimizer packs eight-bit black-and-white grey images to one bit, and Export ▸ Images reads CCITT fax images.- **2026-10-23 (M11, monochrome compression):** The PDF Optimizer and Reduce File Size store black-and-white images (scans, image masks) losslessly as CCITT Group 4 when that is smaller, with a Monochrome Images setting in the Optimizer and `doc_optimize` `mono`. JBIG2 and monochrome downsampling are next.- **2026-10-23 (M7, #4280):** Edit text names each standard stand-in font after its face (`PCEdTimesBold`, ...) instead of one shared `PCEdHelv`. Rewriting a bold paragraph whose subset lacks an accent no longer repoints the paragraphs set earlier in a regular stand-in at Times-Bold, and the editor's frame stays on the paragraph being edited. Pages saved by older builds keep their shared name and are not repaired. Estimates unchanged.- **2026-10-23 (M8, #3205 follow-up):** Phone-pattern redaction matches complete labelled Italian geographic numbers such as `Tel. +39 0426/123456`, with synthetic matcher and mark/apply/save/reopen coverage; unlabelled international slash numbers remain unsupported.diff --git a/crates/automation/src/tools.rs b/crates/automation/src/tools.rsindex 2760be929..15530229f 100644--- a/crates/automation/src/tools.rs+++ b/crates/automation/src/tools.rs@@ -1274,7 +1274,7 @@ pub fn tools() -> Vec<ToolDef> {.ro().cmd("ocr.recognize").with(schema(json!({}), &[])),- t("doc_export_all_images", "Export all images", "Write the images that pages use into a folder (`<name>_Page_<n>_Image_<k>.jpg|png`, n zero-padded to the page count's digits), each once: JPEG images unchanged, others as PNG with their soft mask as alpha. min_size skips images with fewer pixels on their shorter side. Images that can't be decoded yet (JPEG 2000, JBIG2, CCITT, separations) are listed under skipped. Includes unsaved edits.")+ t("doc_export_all_images", "Export all images", "Write the images that pages use into a folder (`<name>_Page_<n>_Image_<k>.jpg|png`, n zero-padded to the page count's digits), each once: JPEG images unchanged, others as PNG with their soft mask as alpha. min_size skips images with fewer pixels on their shorter side. Images that can't be decoded yet (JPEG 2000, JBIG2, separations) are listed under skipped. Includes unsaved edits.").cmd("export.all_images").with(schema(json!({diff --git a/crates/automation/tests/it/automation.rs b/crates/automation/tests/it/automation.rsindex dcd321edd..ea943eff7 100644--- a/crates/automation/tests/it/automation.rs+++ b/crates/automation/tests/it/automation.rs@@ -6431,6 +6431,55 @@ fn scanned_page() -> Vec<u8> {write_full(&doc, &SaveOptions::default()).unwrap()}+/// A scan saved as a 1-bit PNG becomes a page whose picture stays one bit per pixel (not the eight+/// bits the PNG decodes to), and Export all images gives the picture back.+#[test]+fn a_one_bit_scan_stays_one_bit_and_exports() {+ let dir = workdir("bilevel");+ let (w, h) = (800u32, 200u32);+ let stride = (w as usize).div_ceil(8);+ let mut bits = vec![0xFFu8; stride * h as usize];+ for y in 0..h as usize {+ for x in 0..w as usize {+ if y % 25 >= 6 && y % 25 < 18 && (x * 7 + y / 25 * 13) % 11 < 4 {+ bits[y * stride + x / 8] &= !(0x80 >> (x % 8));+ }+ }+ }+ let mut png_bytes = Vec::new();+ {+ let mut enc = png::Encoder::new(&mut png_bytes, w, h);+ enc.set_color(png::ColorType::Grayscale);+ enc.set_depth(png::BitDepth::One);+ enc.write_header().unwrap().write_image_data(&bits).unwrap();+ }+ std::fs::write(dir.join("scan.png"), &png_bytes).unwrap();+ let mut a = auto(&dir);+ let doc = ok(&mut a, "doc_create", json!({ "from": "images", "paths": ["scan.png"] }))["doc"].as_u64().unwrap();+ ok(&mut a, "doc_save", json!({ "doc": doc, "path": "scan.pdf" }));+ let saved = pdfcraft_cos::Document::open(std::sync::Arc::new(std::fs::read(dir.join("scan.pdf")).unwrap())).unwrap();+ let images: Vec<Option<i64>> = saved+ .object_numbers()+ .into_iter()+ .filter_map(|num| match &*saved.get(pdfcraft_cos::ObjRef { num, generation: saved.generation(num) }) {+ pdfcraft_cos::Object::Stream(s) if s.dict.name(b"Subtype") == Some(b"Image") => Some(s.dict.int(b"BitsPerComponent")),+ _ => None,+ })+ .collect();+ assert_eq!(images, [Some(1)]);+ let r = ok(&mut a, "doc_export_all_images", json!({ "doc": doc, "folder": "out" }));+ let files = r["files"].as_array().unwrap();+ assert_eq!(files.len(), 1, "{r}");+ let exported = std::fs::read(files[0]["path"].as_str().unwrap()).unwrap();+ let mut reader = png::Decoder::new(std::io::Cursor::new(exported)).read_info().unwrap();+ let mut buf = vec![0; reader.output_buffer_size().unwrap()];+ let frame = reader.next_frame(&mut buf).unwrap();+ let white: Vec<bool> = buf[..frame.buffer_size()].as_chunks::<3>().0.iter().map(|p| *p == [255, 255, 255]).collect();+ let expected: Vec<bool> =+ (0..h as usize).flat_map(|y| (0..w as usize).map(move |x| (y, x))).map(|(y, x)| bits[y * stride + x / 8] & (0x80 >> (x % 8)) != 0).collect();+ assert_eq!(white, expected);+}+/// A scan's black-and-white image is stored as CCITT Group 4 by default, and kept as it is with/// `mono: { compression: retain }`.#[test]diff --git a/crates/create/Cargo.toml b/crates/create/Cargo.tomlindex 56cebc2af..e60e554ba 100644--- a/crates/create/Cargo.toml+++ b/crates/create/Cargo.toml@@ -11,6 +11,8 @@ workspace = true[dependencies]pdfcraft-cos = { workspace = true }pdfcraft-filters = { workspace = true }+# Already in the graph through hayro: decodes CCITT fax images for Export ▸ Images.+hayro-ccitt.workspace = truepdfcraft-model = { workspace = true }pdfcraft-fonts = { workspace = true }# For `image::bmp_with_pixel_offset`, shared with XFA pictures.@@ -25,6 +27,5 @@ thiserror = { workspace = true }encoding_rs = "0.8"[dev-dependencies]-hayro-ccitt.workspace = trueimage = { version = "0.25", default-features = false, features = ["bmp", "gif", "jpeg"] }hayro-syntax = { workspace = true }diff --git a/crates/create/README.md b/crates/create/README.mdindex d1561a633..e8ed9a872 100644--- a/crates/create/README.md+++ b/crates/create/README.md@@ -6,7 +6,9 @@ Layer L4. Create a PDF (Acrobat's Create a PDF tool), execution plan M10.2:- `from_images(&[(name, bytes)])`: one page per image, sized from the image's resolution(PNG `pHYs`, JPEG JFIF density; 72 dpi when absent). JPEG data is embedded as is(`/DCTDecode`, grey, RGB or Adobe-inverted CMYK); PNG is decoded and stored with Flate,- with transparency as a soft mask. An ICC profile in the file (JPEG `APP2 ICC_PROFILE`, PNG+ with transparency as a soft mask. A picture of only pure black and white (a 1-bit PNG or TIFF,+ eight-bit grey, a two-colour palette, RGB without a profile) is stored at one bit per pixel, as+ CCITT Group 4 or Flate, whichever is smaller as stored (`pdfcraft_filters::encode_g4`). An ICC profile in the file (JPEG `APP2 ICC_PROFILE`, PNG`iCCP`) that matches the image's colour space is kept as an `/ICCBased` colour space withthe device space as `/Alternate`; images with the same profile share one profile object.JPEG metadata scanning skips marker fill bytes and reads application segments after the@@ -31,3 +33,5 @@ Soft-mask Decode intervals map samples to opacity before the mask is resized, inThe existing 16-bit path still uses each sample's high byte.JPEG image Decode handling remains limited.ICC transforms and calibrated color conversion remain outside this export path.+CCITT fax images (Group 3 and 4) are decoded for export through `hayro-ccitt` with their `/DecodeParms`+(`/Columns` has to be the image's width); JPEG 2000 and JBIG2 images are still reported, not exported.diff --git a/crates/create/src/extract.rs b/crates/create/src/extract.rsindex 7828952ed..16ecd5d8d 100644--- a/crates/create/src/extract.rs+++ b/crates/create/src/extract.rs@@ -100,6 +100,92 @@ fn filters(s: &Stream) -> Vec<Vec<u8>> {}}+/// The samples of image `s`, decoded: through its filters, or, for a CCITT fax image (its only+/// filter), through a CCITT decoder, as rows of one-bit samples each starting on a byte, with black+/// as 0 unless `/BlackIs1` says 1, as `CCITTFaxDecode` gives them (ISO 32000-2 §7.4.6).+fn decoded(doc: &Document, s: &Stream) -> Result<Vec<u8>, String> {+ match filters(s).as_slice() {+ [f] if f == b"CCITTFaxDecode" || f == b"CCF" => ccitt(doc, s),+ _ => s.decoded().map_err(|e| e.to_string()),+ }+}++/// [`decoded`] for a CCITT fax image, with its `/DecodeParms` (Table 11 defaults). `/Columns` has to+/// be the image's width; pixels past it and rows past the image's height are dropped, so the output+/// is bounded by the size the caller already checked. A stream that ends early gives fewer rows,+/// which the caller refuses.+fn ccitt(doc: &Document, s: &Stream) -> Result<Vec<u8>, String> {+ struct Rows {+ out: Vec<u8>,+ row: Vec<u8>,+ x: usize,+ columns: usize,+ rows: usize,+ black_is_1: bool,+ }+ impl Rows {+ fn push(&mut self, white: bool, count: usize) {+ for _ in 0..count {+ if self.x < self.columns+ && white != self.black_is_1+ && let Some(b) = self.row.get_mut(self.x / 8)+ {+ *b |= 0x80 >> (self.x % 8);+ }+ self.x = self.x.saturating_add(1);+ }+ }+ }+ impl hayro_ccitt::Decoder for Rows {+ fn push_pixel(&mut self, white: bool) {+ self.push(white, 1);+ }+ fn push_pixel_chunk(&mut self, white: bool, chunks: u32) {+ self.push(white, (chunks as usize).saturating_mul(8));+ }+ fn next_line(&mut self) {+ if self.out.len() / self.row.len().max(1) < self.rows {+ self.out.extend_from_slice(&self.row);+ }+ self.row.fill(0);+ self.x = 0;+ }+ }+ let p = s.dict.get(b"DecodeParms").map(|p| doc.resolve(p)).and_then(|p| p.as_dict().cloned()).unwrap_or_default();+ let flag = |key: &[u8], default: bool| match p.get(key).map(|v| doc.resolve(v)).as_deref() {+ Some(Object::Bool(b)) => *b,+ _ => default,+ };+ let k = p.int(b"K").unwrap_or(0);+ // A row is the image's width: that was checked against the export's size limit, so a hostile+ // /Columns can't size the buffers.+ let columns = u32::try_from(p.int(b"Columns").unwrap_or(1728)).ok().filter(|c| *c > 0).ok_or("the fax image has no columns")?;+ if s.dict.int(b"Width") != Some(i64::from(columns)) {+ return Err("the fax image's columns aren't its width".into());+ }+ let height = s.dict.int(b"Height").and_then(|h| u32::try_from(h).ok()).unwrap_or(0);+ let rows = p.int(b"Rows").and_then(|r| u32::try_from(r).ok()).filter(|r| *r > 0).unwrap_or(height).min(height);+ let settings = hayro_ccitt::DecodeSettings {+ columns,+ rows,+ end_of_block: flag(b"EndOfBlock", true),+ end_of_line: flag(b"EndOfLine", false),+ rows_are_byte_aligned: flag(b"EncodedByteAlign", false),+ encoding: match k {+ ..0 => hayro_ccitt::EncodingMode::Group4,+ 0 => hayro_ccitt::EncodingMode::Group3_1D,+ k => hayro_ccitt::EncodingMode::Group3_2D { k: u32::try_from(k).unwrap_or(u32::MAX) },+ },+ invert_black: false,+ };+ let stride = (columns as usize).div_ceil(8);+ let mut out =+ Rows { out: Vec::new(), row: vec![0; stride], x: 0, columns: columns as usize, rows: rows as usize, black_is_1: flag(b"BlackIs1", false) };+ // Rows decoded before damaged data are kept; too few rows are refused by the caller.+ let _ = hayro_ccitt::decode(&s.raw, &mut out, &mut hayro_ccitt::DecoderContext::new(settings));+ Ok(out.out)+}+/// The file for one image: its JPEG data as is, or a PNG. An image with transparency (a soft/// mask, a stencil `/Mask` or a colour-key `/Mask`) is always a PNG with that transparency as/// alpha, JPEG images included, so cut-out images keep their transparent background.@@ -109,7 +195,6 @@ fn image(doc: &Document, s: &Stream) -> Result<(&'static str, Vec<u8>), String>match f.last().map(Vec::as_slice) {Some(b"JPXDecode") => return Err("JPEG 2000 images can't be exported yet".into()),Some(b"JBIG2Decode") => return Err("JBIG2 images can't be exported yet".into()),- Some(b"CCITTFaxDecode" | b"CCF") => return Err("CCITT fax images can't be exported yet".into()),Some(b"DCTDecode" | b"DCT") if !jpeg => return Err("JPEG images inside other filters can't be exported yet".into()),_ => {}}@@ -148,7 +233,7 @@ fn image(doc: &Document, s: &Stream) -> Result<(&'static str, Vec<u8>), String>space = decoded;(samples, 8)} else {- let data = s.decoded().map_err(|e| e.to_string())?;+ let data = decoded(doc, s)?;let bpc = if mask { 1 } else { s.dict.int(b"BitsPerComponent").unwrap_or(8) };let bpc = match bpc {1 => 1,@@ -466,7 +551,7 @@ fn stencil_mask(doc: &Document, s: &Stream, w: usize, h: usize) -> Option<Vec<u8}/// A one-component mask image as 8-bit values (its `/Decode` interval applied), scaled to-/// `w` × `h`. `None` when it can't be decoded (JPEG 2000, JBIG2 and CCITT masks).+/// `w` × `h`. `None` when it can't be decoded (JPEG 2000 and JBIG2 masks).fn gray_plane(doc: &Document, m: &Stream, w: usize, h: usize) -> Option<Vec<u8>> {let (mw, mh) = size(m.dict.int(b"Width")?, m.dict.int(b"Height")?)?;let stencil = m.dict.get(b"ImageMask").is_some_and(|v| matches!(&*doc.resolve(v), Object::Bool(true)));@@ -476,7 +561,7 @@ fn gray_plane(doc: &Document, m: &Stream, w: usize, h: usize) -> Option<Vec<u8>>let img = image::load_from_memory_with_format(&m.raw, image::ImageFormat::Jpeg).ok()?.into_luma8();(img.width() as usize == mw && img.height() as usize == mh).then(|| img.into_raw())?}- Some(b"DCTDecode" | b"DCT" | b"JPXDecode" | b"JBIG2Decode" | b"CCITTFaxDecode" | b"CCF") => return None,+ Some(b"DCTDecode" | b"DCT" | b"JPXDecode" | b"JBIG2Decode") => return None,_ => {let bpc = if stencil { 1 } else { m.dict.int(b"BitsPerComponent").unwrap_or(8) };let bpc = match bpc {@@ -488,7 +573,7 @@ fn gray_plane(doc: &Document, m: &Stream, w: usize, h: usize) -> Option<Vec<u8>>_ => return None,};let max = (1u32 << bpc.min(8)) - 1;- unpack(&m.decoded().ok()?, mw, mh, 1, bpc)?.into_iter().map(|v| (v as u32 * 255 / max) as u8).collect()+ unpack(&decoded(doc, m).ok()?, mw, mh, 1, bpc)?.into_iter().map(|v| (v as u32 * 255 / max) as u8).collect()}};if let Some([lo, hi]) = decode(doc, m, 1).and_then(|pairs| pairs.first().copied()) {diff --git a/crates/create/src/tests.rs b/crates/create/src/tests.rsindex f94fc020a..9716470ab 100644--- a/crates/create/src/tests.rs+++ b/crates/create/src/tests.rs@@ -1506,3 +1506,60 @@ fn black_and_white_images_are_stored_at_one_bit() {);assert_eq!(kept[3], (Some(1), Some(b"FlateDecode".to_vec())), "Group 4 isn't smaller for 2 × 2");}++/// The pixels of an exported PNG (RGB), as true for white.+fn exported_white(png_data: &[u8]) -> Vec<bool> {+ let mut reader = png::Decoder::new(std::io::Cursor::new(png_data.to_vec())).read_info().unwrap();+ let mut buf = vec![0; reader.output_buffer_size().unwrap()];+ let frame = reader.next_frame(&mut buf).unwrap();+ assert_eq!(frame.color_type, png::ColorType::Rgb);+ buf[..frame.buffer_size()].as_chunks::<3>().0.iter().map(|p| *p == [255, 255, 255]).collect()+}++/// Export ▸ Images reads CCITT fax images: a page created from a 1-bit PNG (Group 4 now) exports as+/// the picture, as does the picture coded the other way round with /BlackIs1. One whose /Columns+/// aren't its width is skipped, not misread.+#[test]+fn ccitt_fax_images_export_as_their_picture() {+ use png::{BitDepth, ColorType};+ let (w, h) = (1200u32, 240u32);+ let bits = strokes(w, h);+ let stride = (w as usize).div_ceil(8);+ let picture: Vec<bool> =+ (0..h as usize).flat_map(|y| (0..w as usize).map(move |x| (y, x))).map(|(y, x)| bits[y * stride + x / 8] & (0x80 >> (x % 8)) != 0).collect();+ let mut doc = from_images(&[("scan.png".into(), png_of(w, h, ColorType::Grayscale, BitDepth::One, &bits, None, None))]).unwrap();+ assert_eq!(image_of(&doc, 0).name(b"Filter"), Some(&b"CCITTFaxDecode"[..]));+ let out = extract_images(&doc, &[0], 0);+ assert!(out.skipped.is_empty(), "{:?}", out.skipped);+ assert_eq!(exported_white(&out.images[0].data), picture);++ // The same picture coded with 1 for black, which /BlackIs1 says.+ let r = {+ let page = pdfcraft_model::pages(&doc)[0].clone();+ let res = doc.resolve(page.dict.get(b"Resources").unwrap()).as_dict().cloned().unwrap();+ let xo = doc.resolve(res.get(b"XObject").unwrap()).as_dict().cloned().unwrap();+ xo.get(b"Im0").and_then(Object::as_ref).unwrap()+ };+ let base = image_of(&doc, 0);+ let with = |black_is_1: bool, columns: i64, data: Vec<u8>| {+ let mut d = base.clone();+ let mut parms = Dict::new();+ parms.set(b"K".to_vec(), Object::Int(-1));+ parms.set(b"Columns".to_vec(), Object::Int(columns));+ parms.set(b"Rows".to_vec(), Object::Int(i64::from(h)));+ parms.set(b"BlackIs1".to_vec(), Object::Bool(black_is_1));+ d.set(b"DecodeParms".to_vec(), Object::Dict(parms));+ d.remove(b"Length");+ Stream::from_raw(d, data)+ };+ let inverted: Vec<u8> = bits.iter().map(|b| !b).collect();+ let stream = with(true, i64::from(w), pdfcraft_filters::encode_g4(&inverted, w, h).unwrap());+ doc.set(r, Object::Stream(stream));+ let out = extract_images(&doc, &[0], 0);+ assert_eq!(exported_white(&out.images[0].data), picture, "BlackIs1");++ let stream = with(false, i64::from(w) + 8, pdfcraft_filters::encode_g4(&bits, w, h).unwrap());+ doc.set(r, Object::Stream(stream));+ let out = extract_images(&doc, &[0], 0);+ assert!(out.images.is_empty() && out.skipped.len() == 1, "columns other than the width: skipped");+}diff --git a/crates/optimize/README.md b/crates/optimize/README.mdindex c3281f00c..bfd3dad7d 100644--- a/crates/optimize/README.md+++ b/crates/optimize/README.md@@ -37,14 +37,13 @@ let report = optimize_with_progress(&mut doc, &settings, &mut |stage| keep_going- **Monochrome images** (`Settings::mono`, CCITT Group 4 by default): a 1-bit image with onecolour component (grey, indexed, a separation) or an image mask, stored with no filter or withgeneral-purpose ones, is stored again as CCITT Group 4 (`pdfcraft_filters::encode_g4`) when- that is smaller as stored. It is lossless: the samples decode to the same bits, so the colour+ that is smaller as stored. An eight-bit grey image of only 0 and 255 is packed to one bit first+ (not an indexed image, whose samples are palette indices, nor one with a colour-key `/Mask`). It is lossless: the samples decode to the same bits, so the colourspace, decode array and masks stay. Group 4 wins on scans, whose ragged edges defeat Flate;on clean computer-drawn 1-bit art Flate can be smaller, and the image then stays. Not yet:JBIG2, monochrome downsampling, inline images, soft masks and `/Mask` images, and rows widerthan 32,767 samples. Redaction doesn't decode Group 4 yet: a mark over part of an image stored- this way removes the whole image (nothing leaks). Nor does anything that exports an image:- Export ▸ Images and Save Image As refuse it, Copy Image fails, and Word, PowerPoint and HTML- export leave the picture out.+ this way removes the whole image (nothing leaks).- **Discard objects:** thumbnails, alternate images, document tags, print settings.- **Clean up:** Flate for streams with no filter; for streams with an outer ASCII85 or ASCIIHexlayer, that layer is removed when the result is smaller (the inner filters keep their encodeddiff --git a/docs/roadmap.md b/docs/roadmap.mdindex 75be8e383..1ebbb025a 100644--- a/docs/roadmap.md+++ b/docs/roadmap.md@@ -2,6 +2,7 @@> **Last reviewed:** 2026-10-27 | **Last updated:** 2026-10-27 | **Change:** minor (M10: OCR model downloads use verified ONNX pairs with legacy discovery fallback; estimates unchanged)> **Last reviewed:** 2026-10-25 | **Last updated:** 2026-10-25 | **Change:** minor (M14 localization current state: Arabic logical catalog, explicit RTL label direction and mirrored stock chrome; native/browser RTL workflows unqualified. Native release Hans face via LXGW WenKai Lite; estimates unchanged)+> **Last reviewed:** 2026-10-24 · **Last updated:** 2026-10-24 · **Change:** minor (M11: black-and-white pictures stay one bit when PDFs are created and optimized; CCITT images export; estimates unchanged)> **Last reviewed:** 2026-10-23 · **Last updated:** 2026-10-23 · **Change:** minor (M11: the PDF Optimizer and Reduce File Size store black-and-white images as CCITT Group 4 when smaller; estimates unchanged)> **Last reviewed:** 2026-10-23 · **Last updated:** 2026-10-23 · **Change:** minor (M7, #2636 partial: pasting added text boxes and images in the engine and through `content_copy`; estimates unchanged)> **Last reviewed:** 2026-10-23 · **Last updated:** 2026-10-23 · **Change:** minor (M11: image optimization accounts for page-local UserUnit; estimates unchanged)@@ -256,6 +257,7 @@ Estimates unchanged.| Date | Change | Summary ||---|---|---|+| 2026-10-24 | minor | M11: Create PDF stores pictures of only black and white at one bit (Group 4 or Flate, whichever is smaller) instead of eight-bit grey; the optimizer packs eight-bit black-and-white grey images to one bit before Monochrome Images compresses them; Export ▸ Images decodes CCITT fax images. Estimates unchanged. || 2026-10-23 | minor | M11: black-and-white images (1-bit, and image masks) are stored losslessly as CCITT Group 4 when that is smaller: PDF Optimizer ▸ Images ▸ Monochrome Images (on by default, so Reduce File Size too), `doc_optimize` `mono`; `pdfcraft_filters::encode_g4`. JBIG2 and monochrome downsampling not yet. Estimates unchanged. || 2026-10-27 | minor | M10: OCR stages SHA-256-verified ONNX models after the upstream RTEN URL brownout; discovery prefers a complete ONNX pair per directory, falls back to a complete RTEN pair, and never mixes formats or directories; language/web limits and estimates unchanged. || 2026-10-24 | minor | M3, #3970 follow-up: the button release given back after a window move or resize goes before the pointer leaving, so hover doesn't stick. Estimates unchanged. |diff --git a/parity/acrobat-features.toml b/parity/acrobat-features.tomlindex 02d7219ab..e7c515e61 100644--- a/parity/acrobat-features.toml+++ b/parity/acrobat-features.toml@@ -6884,8 +6884,8 @@ milestone = "M10"status = "shipped"commands = ["create.images"]tools = ["doc_create"]-evidence = ["crates/create/src/tests.rs::jpeg_2000_images_are_embedded_as_is", "crates/create/src/tests.rs::images_export_as_jpeg_unchanged_and_others_as_png", "crates/create/src/tests.rs::embedded_icc_profiles_tag_the_image_colour_space"]-notes = "PNG, JPEG, TIFF (multi-page), GIF (first frame), BMP, and JPEG 2000 (JP2 or codestream, embedded as JPXDecode with its capture resolution). JPEG and PNG ICC profiles are kept as /ICCBased; TIFF profiles are not read yet"+evidence = ["crates/create/src/tests.rs::black_and_white_images_are_stored_at_one_bit", "crates/create/src/tests.rs::jpeg_2000_images_are_embedded_as_is", "crates/create/src/tests.rs::images_export_as_jpeg_unchanged_and_others_as_png", "crates/create/src/tests.rs::embedded_icc_profiles_tag_the_image_colour_space"]+notes = "PNG, JPEG, TIFF (multi-page), GIF (first frame), BMP, and JPEG 2000 (JP2 or codestream, embedded as JPXDecode with its capture resolution). JPEG and PNG ICC profiles are kept as /ICCBased; TIFF profiles are not read yet. A picture of only pure black and white (a 1-bit PNG or TIFF, eight-bit grey, a two-colour palette, RGB without a profile) is stored at one bit per pixel, as CCITT Group 4 or Flate, whichever is smaller"[[feature]]id = "create.from-multipage-tiff"@@ -7164,8 +7164,8 @@ milestone = "M10"status = "shipped"commands = ["export.all_images"]tools = ["doc_export_all_images"]-evidence = ["crates/create/src/tests.rs::images_export_as_jpeg_unchanged_and_others_as_png", "crates/create/src/tests.rs::indexed_and_one_bit_images_decode", "crates/create/src/tests.rs::jpeg_images_with_a_soft_mask_export_as_png_with_alpha", "crates/create/src/tests.rs::soft_masks_of_another_size_and_stencil_and_colour_key_masks_become_alpha", "crates/create/src/tests.rs::soft_mask_decode_ranges_become_exported_alpha", "crates/create/src/tests.rs::soft_mask_decode_maps_packed_and_jpeg_masks_before_resizing", "crates/automation/tests/it/automation.rs::exporting_all_images_through_tools", "crates/ui-egui/tests/it/export.rs::export_dialogs_write_images_and_text", "crates/create/src/tests.rs::lossless_decode_maps_each_component_before_colour_conversion", "crates/create/src/tests.rs::lossless_indexed_decode_rounds_in_index_units_then_clamps"]-notes = "each image once (page resources and nested forms); JPEG unchanged unless it has transparency, others PNG (gray/RGB/CMYK/ICC/Indexed, 1–16 bpc, stencil masks); transparency as PNG alpha: /SMask (scaled to the image size, /Matte un-blended), stencil /Mask and colour-key /Mask, JPEG images included (#645); JPX/JBIG2/CCITT masks are left out (image exported opaque); JPX/JBIG2/CCITT/separations reported as skipped; minimum size filter. Lossless images apply per-component Decode; Indexed values round and clip before palette lookup. Missing, null or malformed Decode arrays keep the default mapping. Soft-mask Decode intervals preserve opacity before resizing, including indirect arrays and endpoints. Still limited: 16-bit samples use high bytes; general JPEG image Decode, ICC transforms, and calibrated colors remain unsupported."+evidence = ["crates/create/src/tests.rs::ccitt_fax_images_export_as_their_picture", "crates/create/src/tests.rs::images_export_as_jpeg_unchanged_and_others_as_png", "crates/create/src/tests.rs::indexed_and_one_bit_images_decode", "crates/create/src/tests.rs::jpeg_images_with_a_soft_mask_export_as_png_with_alpha", "crates/create/src/tests.rs::soft_masks_of_another_size_and_stencil_and_colour_key_masks_become_alpha", "crates/create/src/tests.rs::soft_mask_decode_ranges_become_exported_alpha", "crates/create/src/tests.rs::soft_mask_decode_maps_packed_and_jpeg_masks_before_resizing", "crates/automation/tests/it/automation.rs::exporting_all_images_through_tools", "crates/ui-egui/tests/it/export.rs::export_dialogs_write_images_and_text", "crates/create/src/tests.rs::lossless_decode_maps_each_component_before_colour_conversion", "crates/create/src/tests.rs::lossless_indexed_decode_rounds_in_index_units_then_clamps"]+notes = "each image once (page resources and nested forms); JPEG unchanged unless it has transparency, others PNG (gray/RGB/CMYK/ICC/Indexed, 1–16 bpc, stencil masks); transparency as PNG alpha: /SMask (scaled to the image size, /Matte un-blended), stencil /Mask and colour-key /Mask, JPEG images included (#645); JPX/JBIG2 masks are left out (image exported opaque); JPX/JBIG2/separations reported as skipped; minimum size filter. Lossless images apply per-component Decode; Indexed values round and clip before palette lookup. Missing, null or malformed Decode arrays keep the default mapping. Soft-mask Decode intervals preserve opacity before resizing, including indirect arrays and endpoints. Still limited: 16-bit samples use high bytes; general JPEG image Decode, ICC transforms, and calibrated colors remain unsupported. CCITT fax images (Group 3 and 4, with their /DecodeParms) export as their picture, masks included."[[feature]]id = "create.export-html"@@ -7384,8 +7384,8 @@ milestone = "M11"status = "partial"commands = ["optimize.advanced", "optimize.reduce"]tools = ["doc_optimize", "doc_reduce"]-evidence = ["crates/filters/src/ccitt.rs::bitmaps_round_trip", "crates/filters/src/ccitt.rs::a_page_of_text_like_marks_round_trips_and_shrinks", "crates/filters/src/ccitt.rs::what_it_cannot_encode_is_an_error", "crates/optimize/tests/optimize.rs::black_and_white_images_become_ccitt_group_4", "crates/automation/tests/it/automation.rs::doc_optimize_stores_black_and_white_images_as_ccitt_group_4", "crates/ui-egui/tests/it/create.rs::the_pdf_optimizer_dialog_saves_an_optimized_copy"]-notes = "CCITT Group 4, lossless: PDF Optimizer ▸ Images ▸ Monochrome Images (on by default, so Reduce File Size does it too; doc_optimize mono) stores a 1-bit image of one colour component (grey, indexed, a separation) or an image mask, kept with no filter or general-purpose ones, as Group 4 when that is smaller as stored; the samples decode to the same bits, so colour space, decode array and masks stay. Group 4 wins on scans; on clean computer-drawn 1-bit art Flate can be smaller, and the image then stays. Not yet: JBIG2 (lossless or lossy, which Adobe's help says beats CCITT for monochrome), monochrome downsampling, inline images, soft masks and /Mask images, rows wider than 32,767 samples. Redaction doesn't decode Group 4 yet (a mark over part of such an image removes it whole; nothing leaks), nor does anything that exports an image: Export ▸ Images and Save Image As refuse it, Copy Image fails, and Word, PowerPoint and HTML export leave the picture out."+evidence = ["crates/optimize/tests/optimize.rs::eight_bit_black_and_white_images_become_one_bit", "crates/filters/src/ccitt.rs::bitmaps_round_trip", "crates/filters/src/ccitt.rs::a_page_of_text_like_marks_round_trips_and_shrinks", "crates/filters/src/ccitt.rs::what_it_cannot_encode_is_an_error", "crates/optimize/tests/optimize.rs::black_and_white_images_become_ccitt_group_4", "crates/automation/tests/it/automation.rs::doc_optimize_stores_black_and_white_images_as_ccitt_group_4", "crates/ui-egui/tests/it/create.rs::the_pdf_optimizer_dialog_saves_an_optimized_copy"]+notes = "CCITT Group 4, lossless: PDF Optimizer ▸ Images ▸ Monochrome Images (on by default, so Reduce File Size does it too; doc_optimize mono) stores a 1-bit image of one colour component (grey, indexed, a separation) or an image mask, kept with no filter or general-purpose ones, as Group 4 when that is smaller as stored; the samples decode to the same bits, so colour space, decode array and masks stay. An eight-bit grey image of only black and white is packed to one bit first, then stored the same way (indexed images and colour-key masks aside). Group 4 wins on scans; on clean computer-drawn 1-bit art Flate can be smaller, and the image then stays. Not yet: JBIG2 (lossless or lossy, which Adobe's help says beats CCITT for monochrome), monochrome downsampling, inline images, soft masks and /Mask images, rows wider than 32,767 samples. Redaction doesn't decode Group 4 yet (a mark over part of such an image removes it whole; nothing leaks)."[[feature]]id = "optimize.only-if-smaller"