PdfCraft: An open-source PDF reader and editor written by scratch in pure Rust
M11: Reduce File Size's descriptions say black-and-white images go to 300 ppi
Grzegorz Martens8bd156a4ac0d
diff --git a/crates/automation/src/tools.rs b/crates/automation/src/tools.rsindex 8767b4dc4..cdf62ebd8 100644--- a/crates/automation/src/tools.rs+++ b/crates/automation/src/tools.rs@@ -1332,7 +1332,7 @@ pub fn tools() -> Vec<ToolDef> {}),&["from"],)),- t("doc_reduce", "Reduce file size", "Write a smaller copy of the document to `path` with Acrobat's Reduce File Size choices: colour and grey images above 225 ppi downsampled to 150 ppi and JPEG-compressed (medium quality), black-and-white images stored as CCITT Group 4 whenever that is smaller, thumbnails dropped, identical fonts and images merged, unused objects dropped, compressed object streams. If the copy wouldn't be smaller, nothing is written and `written` is false. The open document is unchanged.")+ t("doc_reduce", "Reduce file size", "Write a smaller copy of the document to `path` with Acrobat's Reduce File Size choices: colour and grey images above 225 ppi downsampled to 150 ppi and JPEG-compressed (medium quality), black-and-white images averaged down to 300 ppi above 450 ppi and each stored as CCITT Group 4 (or 1-bit Flate, once resampled) whenever that is smaller, thumbnails dropped, identical fonts and images merged, unused objects dropped, compressed object streams. If the copy wouldn't be smaller, nothing is written and `written` is false. The open document is unchanged.").cmd("optimize.reduce").with(schema(json!({ "doc": doc(), "path": { "type": "string" } }), &["doc", "path"])),t("doc_initial_view", "Initial view", "Read or change how the document opens (Document Properties ▸ Initial View) and its reading options: navigation (page, bookmarks, pages, attachments, layers), layout (default, single, continuous, two_up, two_up_continuous, two_up_cover, two_up_continuous_cover), magnification (default, actual, fit_page, fit_width, fit_height, fit_visible, or a percentage), page, window options (fit_window, center_window, full_screen, display_title), interface options (hide_menubar, hide_toolbar, hide_window_ui), language and binding (left, right). Only the given ones change; returns the result. Undoable.").with(schema(diff --git a/crates/engine/src/session/files.rs b/crates/engine/src/session/files.rsindex 5453163ac..34d75e5c8 100644--- a/crates/engine/src/session/files.rs+++ b/crates/engine/src/session/files.rs@@ -69,10 +69,11 @@ impl Session {}/// Reduce File Size: Acrobat's defaults (colour and grey images above 225 ppi to 150 ppi,- /// JPEG medium quality; black-and-white stored as CCITT Group 4 whenever smaller; thumbnails- /// dropped), identical resources merged, unused objects dropped, objects packed into- /// compressed object streams. Returns the bytes and how many objects were merged. The open- /// document is not changed (Acrobat saves the reduced copy as a new file).+ /// JPEG medium quality; black-and-white averaged down to 300 ppi above 450 ppi, and stored as+ /// CCITT Group 4 whenever smaller; thumbnails dropped), identical resources merged, unused+ /// objects dropped, objects packed into compressed object streams. Returns the bytes and how+ /// many objects were merged. The open document is not changed (Acrobat saves the reduced copy+ /// as a new file).pub fn reduced_bytes(&self, id: DocId) -> Result<(Arc<Vec<u8>>, usize), EditError> {let (bytes, report) = self.optimized_bytes(id, &optimize::Settings::default(), &[])?;Ok((bytes, report.merged))diff --git a/crates/optimize/README.md b/crates/optimize/README.mdindex d0a412a31..3ff33728d 100644--- a/crates/optimize/README.md+++ b/crates/optimize/README.md@@ -11,7 +11,9 @@ let report = optimize_with_progress(&mut doc, &settings, &mut |stage| keep_going```- **Presets:** Standard (Reduce File Size's choices: images above 225 ppi to 150 ppi, JPEG- medium) and Mobile (above 144 ppi to 96 ppi, JPEG high), as in Acrobat's Settings menu.+ medium) and Mobile (above 144 ppi to 96 ppi, JPEG high), as in Acrobat's Settings menu. In+ both, black-and-white images are averaged down to 300 ppi above 450 ppi, and stored as CCITT+ Group 4 whenever that is smaller.- **Merge image fragments** (`fragments`, on by default): some PDF printers draw a page pictureas thousands of images one pixel row high. Runs of upright 8-bit grey or RGB images in onecolour space, sharing their left and right edges and stacked edge to edge (at least four,diff --git a/parity/acrobat-features.toml b/parity/acrobat-features.tomlindex c9ca864d4..6e67d4aa9 100644--- a/parity/acrobat-features.toml+++ b/parity/acrobat-features.toml@@ -7325,7 +7325,7 @@ status = "shipped"commands = ["optimize.reduce"]tools = ["doc_reduce"]evidence = ["crates/ui-egui/tests/it/create.rs::reduce_file_size_writes_a_compact_copy", "crates/ui-egui/tests/it/create.rs::reduce_file_size_saves_nothing_when_the_file_is_already_small", "crates/engine/src/tests.rs::create_and_reduce", "crates/automation/tests/it/automation.rs::creating_and_reducing_through_tools", "crates/automation/tests/it/automation.rs::optimizing_through_tools", "crates/optimize/tests/optimize.rs::an_identity_decode_array_does_not_stop_reduce"]-notes = "images above 225 ppi to 150 ppi JPEG medium (after merging page pictures printed as one-pixel strips into one image), black-and-white images to CCITT Group 4 when that is smaller, thumbnails dropped, resources merged, object streams; scanner images with the default decode array are included; a copy that isn't smaller is not saved (\"already as small as it can be made\"); runs in the background with a progress bar and Cancel"+notes = "images above 225 ppi to 150 ppi JPEG medium (after merging page pictures printed as one-pixel strips into one image), black-and-white images averaged down to 300 ppi above 450 ppi, and stored as CCITT Group 4 whenever that is smaller, thumbnails dropped, resources merged, object streams; scanner images with the default decode array are included; a copy that isn't smaller is not saved (\"already as small as it can be made\"); runs in the background with a progress bar and Cancel"[[feature]]id = "optimize.compatibility-level"