From 0ff88f981d6e1eff535de7197a4aafe727301920 Mon Sep 17 00:00:00 2001 From: Hamza Date: Wed, 18 Nov 2026 16:39:17 +0500 Subject: [PATCH 1/4] Separations: say when the resolution was lowered to fit the plate size (#2945) ink.separations accepts 9-300 dpi, but craft-prepress renders each plate within 4 megapixels, so a page larger than A5 at 300 dpi was separated at less with an empty warnings list. separate() now adds a warning naming the resolution used and the one asked for, and the command's params text says the resolution is lowered to fit 4 megapixels per plate. --- crates/engine/src/cmd/prepress.rs | 2 +- crates/engine/src/separations.rs | 40 +++++++++++++++++++++++++++++-- 2 files changed, 39 insertions(+), 3 deletions(-) diff --git a/crates/engine/src/cmd/prepress.rs b/crates/engine/src/cmd/prepress.rs index 4eb15a6eb..c48f26b0d 100644 --- a/crates/engine/src/cmd/prepress.rs +++ b/crates/engine/src/cmd/prepress.rs @@ -10,7 +10,7 @@ const ID: &str = "ink.separations"; pub fn specs() -> Vec { vec![cmd!(query "ink.separations", "Separations Preview", [], None, - "{page?: 1-based page position (default 1; its spread is separated), dpi?: 9–300 (default 72), inkLimit?: percent, standard?: none|x4|a2b, compressImages?: bool, flatten?: high|medium|low|ppi (as file.exportPdf)} — the spread exported as Export PDF prints it and separated → {spread, dpi, width, height, conversion, inks: [{name, spot, max, mean, area} (percent)], unseparated: [spot names past 32], maxTotal, maxTotalAt?: [x, y] (pt, spread), overLimit?: {limit, pixels, regions: [{x, y, width, height}] (pt, spread)}, warnings}", + "{page?: 1-based page position (default 1; its spread is separated), dpi?: 9–300 (default 72; lowered to fit 4 megapixels per plate, as on pages larger than A5 at 300, which `dpi` and a warning then say), inkLimit?: percent, standard?: none|x4|a2b, compressImages?: bool, flatten?: high|medium|low|ppi (as file.exportPdf)} — the spread exported as Export PDF prints it and separated → {spread, dpi, width, height, conversion, inks: [{name, spot, max, mean, area} (percent)], unseparated: [spot names past 32], maxTotal, maxTotalAt?: [x, y] (pt, spread), overLimit?: {limit, pixels, regions: [{x, y, width, height}] (pt, spread)}, warnings}", has_doc, separations)] } diff --git a/crates/engine/src/separations.rs b/crates/engine/src/separations.rs index a13b8af4f..0dba35958 100644 --- a/crates/engine/src/separations.rs +++ b/crates/engine/src/separations.rs @@ -77,7 +77,9 @@ pub struct Print { /// Exports spread `si` as Export PDF prints it with `print` (one page for the spread, with /// the document bleed, without printer's marks) and separates it at `dpi`, clamped to -/// [`MIN_DPI`]–[`MAX_DPI`]. +/// [`MIN_DPI`]–[`MAX_DPI`]. A spread larger than [`craft_prepress::MAX_PLATE_PIXELS`] at that +/// resolution is separated at a lower one; `plates.dpi` says which, and a warning says it was +/// lowered (#2945). pub fn separate(doc: &Document, cache: &Cache, si: usize, dpi: f32, print: &Print) -> Result { let sp = doc.spreads.get(si).ok_or_else(|| EngineError::Other(format!("spread {si} does not exist")))?; let first = doc.first_page_of_spread(si); @@ -96,7 +98,18 @@ pub fn separate(doc: &Document, cache: &Cache, si: usize, dpi: f32, print: &Prin let (fallback, cms) = printing_condition(); let plates = craft_prepress::plates(&report.bytes, 0, dpi, &Options { overprint: true, fallback }) .map_err(|e| EngineError::Other(format!("separations: {e}")))?; - Ok(Sheet { spread: si, area, plates, cms, warnings: report.warnings }) + let mut warnings = report.warnings; + // Total-ink checks depend on resolution (a thin rich-black rule averages under the limit at a + // low one), so a resolution lowered to fit the plate size is said, not only reported. + if plates.dpi < dpi - 0.5 { + warnings.push(format!( + "separated at {:.0} dpi, not the {:.0} dpi asked for: at that resolution the spread would be more than {:.0} megapixels per plate", + plates.dpi, + dpi, + craft_prepress::MAX_PLATE_PIXELS / 1.0e6 + )); + } + Ok(Sheet { spread: si, area, plates, cms, warnings }) } impl Sheet { @@ -199,6 +212,29 @@ mod tests { assert!((inked as f64 - square).abs() < square * 0.1, "{inked} dark pixels, the square has {square}"); } + /// #2945: a page too large for 4 megapixels a plate at the dpi asked for is separated at a + /// lower one, and the result says so; one that fits says nothing. + #[test] + fn a_lowered_resolution_is_a_warning() { + let run = |preset: &str, dpi: u32| { + let mut s = Session::new(); + s.execute("file.new", &json!({"preset": preset, "facingPages": false, "pages": 1})).unwrap(); + s.execute("ink.separations", &json!({"dpi": dpi})).unwrap() + }; + let lowered = |r: &serde_json::Value| { + r["warnings"].as_array().unwrap().iter().filter(|w| w.as_str().is_some_and(|w| w.contains("dpi asked for"))).count() + }; + let a3 = run("A3", 300); + let used = a3["dpi"].as_f64().unwrap(); + assert!(used < 150.0, "{a3}"); + assert_eq!(lowered(&a3), 1, "{a3}"); + let text = a3["warnings"][0].as_str().unwrap_or_default(); + assert!(text.contains(&format!("{used:.0} dpi")) && text.contains("300 dpi"), "{text}"); + let a5 = run("A5", 72); + assert_eq!(a5["dpi"].as_f64(), Some(72.0)); + assert_eq!(lowered(&a5), 0, "{a5}"); + } + #[test] fn ink_limit_flags_the_400_percent_area() { let mut s = document(); From 15ec895e4f0600f6b8c1e4983d7479f3d361de06 Mon Sep 17 00:00:00 2001 From: Hamza Date: Wed, 18 Nov 2026 16:39:41 +0500 Subject: [PATCH 2/4] Separations: the params text says A5 at 300 dpi is already lowered --- crates/engine/src/cmd/prepress.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/engine/src/cmd/prepress.rs b/crates/engine/src/cmd/prepress.rs index c48f26b0d..b1befd680 100644 --- a/crates/engine/src/cmd/prepress.rs +++ b/crates/engine/src/cmd/prepress.rs @@ -10,7 +10,7 @@ const ID: &str = "ink.separations"; pub fn specs() -> Vec { vec![cmd!(query "ink.separations", "Separations Preview", [], None, - "{page?: 1-based page position (default 1; its spread is separated), dpi?: 9–300 (default 72; lowered to fit 4 megapixels per plate, as on pages larger than A5 at 300, which `dpi` and a warning then say), inkLimit?: percent, standard?: none|x4|a2b, compressImages?: bool, flatten?: high|medium|low|ppi (as file.exportPdf)} — the spread exported as Export PDF prints it and separated → {spread, dpi, width, height, conversion, inks: [{name, spot, max, mean, area} (percent)], unseparated: [spot names past 32], maxTotal, maxTotalAt?: [x, y] (pt, spread), overLimit?: {limit, pixels, regions: [{x, y, width, height}] (pt, spread)}, warnings}", + "{page?: 1-based page position (default 1; its spread is separated), dpi?: 9–300 (default 72; lowered to fit 4 megapixels per plate, as for an A5 page or larger at 300, which `dpi` and a warning then say), inkLimit?: percent, standard?: none|x4|a2b, compressImages?: bool, flatten?: high|medium|low|ppi (as file.exportPdf)} — the spread exported as Export PDF prints it and separated → {spread, dpi, width, height, conversion, inks: [{name, spot, max, mean, area} (percent)], unseparated: [spot names past 32], maxTotal, maxTotalAt?: [x, y] (pt, spread), overLimit?: {limit, pixels, regions: [{x, y, width, height}] (pt, spread)}, warnings}", has_doc, separations)] } From 294cef70d6cfe2a69f6edf85ad812ea442620222 Mon Sep 17 00:00:00 2001 From: "autocraft-bot[bot]" <354215646+autocraft-bot[bot]@users.noreply.github.com> Date: Wed, 18 Nov 2026 12:24:49 +0000 Subject: [PATCH 3/4] Apply review fixes - crates/engine/src/separations.rs --- crates/engine/src/separations.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/crates/engine/src/separations.rs b/crates/engine/src/separations.rs index 0dba35958..7a75fc637 100644 --- a/crates/engine/src/separations.rs +++ b/crates/engine/src/separations.rs @@ -33,7 +33,7 @@ pub struct Sheet { pub plates: Plates, /// The printing condition the composite converts process plates through. cms: CmsConversion, - /// Export warnings. + /// Export warnings, and one when the resolution was lowered to fit the plate size. pub warnings: Vec, } @@ -228,7 +228,8 @@ mod tests { let used = a3["dpi"].as_f64().unwrap(); assert!(used < 150.0, "{a3}"); assert_eq!(lowered(&a3), 1, "{a3}"); - let text = a3["warnings"][0].as_str().unwrap_or_default(); + let text = + a3["warnings"].as_array().and_then(|ws| ws.iter().filter_map(|w| w.as_str()).find(|w| w.contains("dpi asked for"))).unwrap_or_default(); assert!(text.contains(&format!("{used:.0} dpi")) && text.contains("300 dpi"), "{text}"); let a5 = run("A5", 72); assert_eq!(a5["dpi"].as_f64(), Some(72.0)); From 53b80e7196408b41f76b5f0c0b6c6172be2a8d16 Mon Sep 17 00:00:00 2001 From: "autocraft-bot[bot]" <354215646+autocraft-bot[bot]@users.noreply.github.com> Date: Wed, 18 Nov 2026 13:00:36 +0000 Subject: [PATCH 4/4] Apply review fixes - crates/engine/src/separations.rs --- crates/engine/src/separations.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/engine/src/separations.rs b/crates/engine/src/separations.rs index 7a75fc637..64fe3a202 100644 --- a/crates/engine/src/separations.rs +++ b/crates/engine/src/separations.rs @@ -103,7 +103,7 @@ pub fn separate(doc: &Document, cache: &Cache, si: usize, dpi: f32, print: &Prin // low one), so a resolution lowered to fit the plate size is said, not only reported. if plates.dpi < dpi - 0.5 { warnings.push(format!( - "separated at {:.0} dpi, not the {:.0} dpi asked for: at that resolution the spread would be more than {:.0} megapixels per plate", + "separated at {:.0} dpi, not the {:.0} dpi asked for: at that resolution the spread would be more than {:.0} megapixels per plate or 8192 pixels a side", plates.dpi, dpi, craft_prepress::MAX_PLATE_PIXELS / 1.0e6