From 12fe81ca01d7fc3c47a6df6994e4f9d983e0bf46 Mon Sep 17 00:00:00 2001 From: "Dylan M. Taylor" Date: Wed, 18 Nov 2026 16:30:59 -0500 Subject: [PATCH] images: cut over EPS bounding_box and is_eps to craft-ps (#2972) --- Cargo.lock | 19 +++++++++++++++++++ Cargo.toml | 1 + crates/images/Cargo.toml | 1 + crates/images/src/eps.rs | 3 +-- crates/images/src/lib.rs | 2 +- 5 files changed, 23 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 7f96b25db..e0266b7c9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1214,6 +1214,11 @@ dependencies = [ "serde", ] +[[package]] +name = "craft-eps" +version = "0.1.0" +source = "git+https://github.com/storytold/craft-libs?rev=5bd7eb9e88e8574a9cd011accaa9b4beaf4118ac#5bd7eb9e88e8574a9cd011accaa9b4beaf4118ac" + [[package]] name = "craft-eps" version = "0.1.0" @@ -1603,6 +1608,19 @@ dependencies = [ "winsafe", ] +[[package]] +name = "craft-ps" +version = "0.1.0" +source = "git+https://github.com/storytold/craft-libs?rev=5bd7eb9e88e8574a9cd011accaa9b4beaf4118ac#5bd7eb9e88e8574a9cd011accaa9b4beaf4118ac" +dependencies = [ + "craft-eps 0.1.0 (git+https://github.com/storytold/craft-libs?rev=5bd7eb9e88e8574a9cd011accaa9b4beaf4118ac)", + "kurbo", + "miniz_oxide 0.8.9", + "pdf-writer", + "skrifa 0.47.0", + "weezl", +] + [[package]] name = "craft-psd" version = "0.1.0" @@ -2296,6 +2314,7 @@ dependencies = [ "craft-eps 0.1.0 (git+https://github.com/storytold/craft-libs?rev=ba24fe2435adb3c81ad6057faf36365fbba736cf)", "craft-file-formats", "craft-image-codecs 0.1.0 (git+https://github.com/storytold/craft-libs?rev=bfea7d9800a9f14e496209f9df30e9ef45655701)", + "craft-ps", "craft-psd", "craft-svg 0.1.0 (git+https://github.com/storytold/craft-libs?rev=cc23ffd4d26f3074808e2187d332564817624f8f)", "designcraft-color", diff --git a/Cargo.toml b/Cargo.toml index 512ba8145..f58d850ff 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -17,6 +17,7 @@ craft-mime = { version = "0.1.0", git = "https://github.com/storytold/craft-libs craft-pdf = { git = "https://github.com/storytold/craft-libs", rev = "a5ac3aa05cf3ec013961a85599ddd9e0b5c03813", version = "=0.1.0", default-features = false } craft-designcraft-format = { git = "https://github.com/storytold/craft-libs", rev = "b1b4602a71d19e09ad33f7752a10d6598cf39b2b", version = "=0.1.0" } craft-eps = { git = "https://github.com/storytold/craft-libs", rev = "ba24fe2435adb3c81ad6057faf36365fbba736cf", version = "=0.1.0" } +craft-ps = { git = "https://github.com/storytold/craft-libs", rev = "5bd7eb9e88e8574a9cd011accaa9b4beaf4118ac", version = "=0.1.0", features = ["read"] } craft-epub = { git = "https://github.com/storytold/craft-libs", rev = "ba24fe2435adb3c81ad6057faf36365fbba736cf", version = "=0.1.0" } craft-idml = { git = "https://github.com/storytold/craft-libs", rev = "899e396b9e2710fcdf1ad9b6249d6c456b7ca9a2", version = "=0.1.0" } craft-indd = { git = "https://github.com/storytold/craft-libs", rev = "47bf5650b0d503b97bfb5e841746c4957897d11f", version = "=0.1.0" } diff --git a/crates/images/Cargo.toml b/crates/images/Cargo.toml index 3c7559b90..7285f9a13 100644 --- a/crates/images/Cargo.toml +++ b/crates/images/Cargo.toml @@ -10,6 +10,7 @@ workspace = true [dependencies] craft-eps = { workspace = true } +craft-ps = { workspace = true } craft-svg = { workspace = true } designcraft-color = { workspace = true } designcraft-fonts = { workspace = true } diff --git a/crates/images/src/eps.rs b/crates/images/src/eps.rs index 42a2ed885..7e39ff013 100644 --- a/crates/images/src/eps.rs +++ b/crates/images/src/eps.rs @@ -10,8 +10,7 @@ fn sections(bytes: &[u8]) -> (&[u8], Option<&[u8]>) { /// The bounding box in points: (x0, y0, x1, y1), the high-resolution one when given. pub fn bounding_box(bytes: &[u8]) -> Option<[f64; 4]> { - let parts = craft_eps::sections(bytes).ok()?; - craft_eps::Comments::read(parts.postscript).page_box() + craft_ps::read::bounding_box(craft_ps::read::postscript_section(bytes)) } /// Natural EPS dimensions in points. Bound sizes before fitting or allocating a proxy: diff --git a/crates/images/src/lib.rs b/crates/images/src/lib.rs index 6cf733ce4..73eff96cd 100644 --- a/crates/images/src/lib.rs +++ b/crates/images/src/lib.rs @@ -13,7 +13,7 @@ mod jpeg; mod psd; mod resolution; mod tone; -pub use craft_eps::is_eps; +pub use craft_ps::read::is_eps; pub use eps::{bounding_box as eps_bounding_box, eps_pixel_size, eps_png, eps_proxy, eps_size}; pub use tone::{Tone, tone};