diff --git a/Cargo.lock b/Cargo.lock index d9b00f2aa3..bbde79e8c0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1084,10 +1084,11 @@ dependencies = [ [[package]] name = "craft-image-codecs" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=d6cd7836d364177661b0ae17f48a0805e83a5f32#d6cd7836d364177661b0ae17f48a0805e83a5f32" +source = "git+https://github.com/storytold/craft-libs?rev=b3b8521ab4029033a9ffc4ebad53f4901cbdf639#b3b8521ab4029033a9ffc4ebad53f4901cbdf639" dependencies = [ - "craft-jpeg", - "craft-metadata", + "craft-jpeg 0.1.0 (git+https://github.com/storytold/craft-libs?rev=b3b8521ab4029033a9ffc4ebad53f4901cbdf639)", + "craft-metadata 0.1.0 (git+https://github.com/storytold/craft-libs?rev=b3b8521ab4029033a9ffc4ebad53f4901cbdf639)", + "crc32fast", "exr", "flate2", "half", @@ -1105,6 +1106,38 @@ dependencies = [ "zune-jpegxl", ] +[[package]] +name = "craft-image-codecs" +version = "0.1.0" +source = "git+https://github.com/storytold/craft-libs?rev=d6cd7836d364177661b0ae17f48a0805e83a5f32#d6cd7836d364177661b0ae17f48a0805e83a5f32" +dependencies = [ + "craft-jpeg 0.1.0 (git+https://github.com/storytold/craft-libs?rev=d6cd7836d364177661b0ae17f48a0805e83a5f32)", + "craft-metadata 0.1.0 (git+https://github.com/storytold/craft-libs?rev=d6cd7836d364177661b0ae17f48a0805e83a5f32)", + "exr", + "flate2", + "half", + "hayro-jpeg2000", + "image", + "image-webp", + "jpeg-encoder", + "png 0.18.1", + "rayon", + "serde_json", + "thiserror 2.0.21", + "tiff", + "zune-core", + "zune-jpeg", + "zune-jpegxl", +] + +[[package]] +name = "craft-jpeg" +version = "0.1.0" +source = "git+https://github.com/storytold/craft-libs?rev=b3b8521ab4029033a9ffc4ebad53f4901cbdf639#b3b8521ab4029033a9ffc4ebad53f4901cbdf639" +dependencies = [ + "thiserror 2.0.21", +] + [[package]] name = "craft-jpeg" version = "0.1.0" @@ -1133,6 +1166,18 @@ dependencies = [ "serde_json", ] +[[package]] +name = "craft-metadata" +version = "0.1.0" +source = "git+https://github.com/storytold/craft-libs?rev=b3b8521ab4029033a9ffc4ebad53f4901cbdf639#b3b8521ab4029033a9ffc4ebad53f4901cbdf639" +dependencies = [ + "brotli-decompressor 6.3.1", + "chrono", + "craft-tiff 0.1.0 (git+https://github.com/storytold/craft-libs?rev=b3b8521ab4029033a9ffc4ebad53f4901cbdf639)", + "quick-xml 0.41.0", + "serde", +] + [[package]] name = "craft-metadata" version = "0.1.0" @@ -1140,7 +1185,7 @@ source = "git+https://github.com/storytold/craft-libs?rev=d6cd7836d364177661b0ae dependencies = [ "brotli-decompressor 6.3.1", "chrono", - "craft-tiff", + "craft-tiff 0.1.0 (git+https://github.com/storytold/craft-libs?rev=d6cd7836d364177661b0ae17f48a0805e83a5f32)", "quick-xml 0.41.0", "serde", ] @@ -1219,7 +1264,7 @@ name = "craft-svg" version = "0.1.0" source = "git+https://github.com/storytold/craft-libs?rev=d6cd7836d364177661b0ae17f48a0805e83a5f32#d6cd7836d364177661b0ae17f48a0805e83a5f32" dependencies = [ - "craft-image-codecs", + "craft-image-codecs 0.1.0 (git+https://github.com/storytold/craft-libs?rev=d6cd7836d364177661b0ae17f48a0805e83a5f32)", "craft-xml", "flate2", "kurbo 0.13.1", @@ -1231,6 +1276,15 @@ dependencies = [ "vectorcraft-pathops 0.18.0", ] +[[package]] +name = "craft-tiff" +version = "0.1.0" +source = "git+https://github.com/storytold/craft-libs?rev=b3b8521ab4029033a9ffc4ebad53f4901cbdf639#b3b8521ab4029033a9ffc4ebad53f4901cbdf639" +dependencies = [ + "serde", + "thiserror 2.0.21", +] + [[package]] name = "craft-tiff" version = "0.1.0" @@ -6603,7 +6657,7 @@ name = "vectorcraft-affinity" version = "0.24.1" dependencies = [ "craft-affinity", - "craft-image-codecs", + "craft-image-codecs 0.1.0 (git+https://github.com/storytold/craft-libs?rev=b3b8521ab4029033a9ffc4ebad53f4901cbdf639)", "crc32fast", "proptest", ] @@ -6632,7 +6686,7 @@ name = "vectorcraft-cad" version = "0.24.1" dependencies = [ "craft-dxf", - "craft-image-codecs", + "craft-image-codecs 0.1.0 (git+https://github.com/storytold/craft-libs?rev=b3b8521ab4029033a9ffc4ebad53f4901cbdf639)", "image", "kurbo 0.13.1", "serde_json", @@ -6703,7 +6757,7 @@ dependencies = [ name = "vectorcraft-effects" version = "0.24.1" dependencies = [ - "craft-image-codecs", + "craft-image-codecs 0.1.0 (git+https://github.com/storytold/craft-libs?rev=b3b8521ab4029033a9ffc4ebad53f4901cbdf639)", "craft-svg", "image", "kurbo 0.13.1", @@ -6728,7 +6782,7 @@ dependencies = [ "chrono", "craft-docpath", "craft-heif", - "craft-image-codecs", + "craft-image-codecs 0.1.0 (git+https://github.com/storytold/craft-libs?rev=b3b8521ab4029033a9ffc4ebad53f4901cbdf639)", "craft-jxl", "craft-proof", "craft-xml", @@ -6774,7 +6828,7 @@ name = "vectorcraft-eps" version = "0.24.1" dependencies = [ "craft-eps", - "craft-image-codecs", + "craft-image-codecs 0.1.0 (git+https://github.com/storytold/craft-libs?rev=b3b8521ab4029033a9ffc4ebad53f4901cbdf639)", "craft-pdf", "craft-stream-codecs", "encoding_rs", @@ -6852,7 +6906,7 @@ dependencies = [ name = "vectorcraft-mcp" version = "0.24.1" dependencies = [ - "craft-image-codecs", + "craft-image-codecs 0.1.0 (git+https://github.com/storytold/craft-libs?rev=b3b8521ab4029033a9ffc4ebad53f4901cbdf639)", "image", "log", "proptest", @@ -6872,7 +6926,7 @@ dependencies = [ name = "vectorcraft-metafile" version = "0.24.1" dependencies = [ - "craft-image-codecs", + "craft-image-codecs 0.1.0 (git+https://github.com/storytold/craft-libs?rev=b3b8521ab4029033a9ffc4ebad53f4901cbdf639)", "craft-metafile", "image", "kurbo 0.13.1", @@ -6913,7 +6967,7 @@ version = "0.24.1" dependencies = [ "aes", "chrono", - "craft-image-codecs", + "craft-image-codecs 0.1.0 (git+https://github.com/storytold/craft-libs?rev=b3b8521ab4029033a9ffc4ebad53f4901cbdf639)", "craft-pdf", "craft-stream-codecs", "craft-xml", @@ -6947,7 +7001,7 @@ dependencies = [ name = "vectorcraft-plugins" version = "0.24.1" dependencies = [ - "craft-image-codecs", + "craft-image-codecs 0.1.0 (git+https://github.com/storytold/craft-libs?rev=b3b8521ab4029033a9ffc4ebad53f4901cbdf639)", "craft-vectorcraft-format", "log", "serde", @@ -6967,10 +7021,10 @@ name = "vectorcraft-render" version = "0.24.1" dependencies = [ "craft-gif", - "craft-image-codecs", + "craft-image-codecs 0.1.0 (git+https://github.com/storytold/craft-libs?rev=b3b8521ab4029033a9ffc4ebad53f4901cbdf639)", "craft-psd", "craft-stream-codecs", - "craft-tiff", + "craft-tiff 0.1.0 (git+https://github.com/storytold/craft-libs?rev=d6cd7836d364177661b0ae17f48a0805e83a5f32)", "flate2", "image", "log", @@ -7005,7 +7059,7 @@ name = "vectorcraft-svg" version = "0.24.1" dependencies = [ "craft-docpath", - "craft-image-codecs", + "craft-image-codecs 0.1.0 (git+https://github.com/storytold/craft-libs?rev=b3b8521ab4029033a9ffc4ebad53f4901cbdf639)", "craft-svg", "data-url", "flate2", @@ -7034,7 +7088,7 @@ dependencies = [ name = "vectorcraft-testkit" version = "0.24.1" dependencies = [ - "craft-image-codecs", + "craft-image-codecs 0.1.0 (git+https://github.com/storytold/craft-libs?rev=b3b8521ab4029033a9ffc4ebad53f4901cbdf639)", "fax", "kurbo 0.13.1", "proptest", @@ -7081,7 +7135,7 @@ dependencies = [ name = "vectorcraft-tools" version = "0.24.1" dependencies = [ - "craft-image-codecs", + "craft-image-codecs 0.1.0 (git+https://github.com/storytold/craft-libs?rev=b3b8521ab4029033a9ffc4ebad53f4901cbdf639)", "kurbo 0.13.1", "serde", "serde_json", @@ -7098,7 +7152,7 @@ dependencies = [ name = "vectorcraft-trace" version = "0.24.1" dependencies = [ - "craft-image-codecs", + "craft-image-codecs 0.1.0 (git+https://github.com/storytold/craft-libs?rev=b3b8521ab4029033a9ffc4ebad53f4901cbdf639)", "image", "kurbo 0.13.1", "serde", @@ -7113,7 +7167,7 @@ version = "0.24.1" dependencies = [ "bytemuck", "chrono", - "craft-image-codecs", + "craft-image-codecs 0.1.0 (git+https://github.com/storytold/craft-libs?rev=b3b8521ab4029033a9ffc4ebad53f4901cbdf639)", "craft-keymap", "craft-ui", "craft-update", diff --git a/Cargo.toml b/Cargo.toml index fcbe4fca56..5aaa924a33 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -34,7 +34,7 @@ craft-dxf = { git = "https://github.com/storytold/craft-libs", rev = "6d620e971e # WMF, EMF and EMF+ reader (craft-libs#778). craft-metafile = { git = "https://github.com/storytold/craft-libs", rev = "6d620e971e820b517b11a99cad040ebac670e1e2" } craft-xml = { git = "https://github.com/storytold/craft-libs", rev = "d6cd7836d364177661b0ae17f48a0805e83a5f32" } -craft-image-codecs = { git = "https://github.com/storytold/craft-libs", rev = "d6cd7836d364177661b0ae17f48a0805e83a5f32" } +craft-image-codecs = { git = "https://github.com/storytold/craft-libs", rev = "b3b8521ab4029033a9ffc4ebad53f4901cbdf639" } craft-gif = { git = "https://github.com/storytold/craft-libs", rev = "d6cd7836d364177661b0ae17f48a0805e83a5f32" } craft-tiff = { git = "https://github.com/storytold/craft-libs", rev = "d6cd7836d364177661b0ae17f48a0805e83a5f32" } craft-psd = { git = "https://github.com/storytold/craft-libs", rev = "d6cd7836d364177661b0ae17f48a0805e83a5f32" } diff --git a/crates/cad/src/scene.rs b/crates/cad/src/scene.rs index 27a8cc2cce..56ebf9b4ea 100644 --- a/crates/cad/src/scene.rs +++ b/crates/cad/src/scene.rs @@ -1405,7 +1405,15 @@ impl<'a> Scene<'a> { use craft_image_codecs::{ChannelLayout, EncodeOptions, Format, Image as CodecImage, SampleType}; let blob = self.doc.image_blob(im).filter(|b| !b.bytes.is_empty()).ok_or_else(|| "an image has no pixels and was left out".to_string())?; // The pixels it converts to (RGBA, 4 bytes each) are read from its header before decoding. - let (w, h) = craft_image_codecs::probe_size(&blob.bytes).map_err(|_| UNDECODED.to_string())?; + let (w, h) = match craft_image_codecs::detect(&blob.bytes) { + Some(Format::Png | Format::Jpeg | Format::Bmp | Format::Tiff) => { + // The generic probe does not cover these stored raster dimensions. + let limits = craft_image_codecs::Limits { max_width: u32::MAX, max_height: u32::MAX, max_pixels: u64::MAX, ..Default::default() }; + craft_image_codecs::probe_stored_size(&blob.bytes, &limits) + } + _ => craft_image_codecs::probe_size(&blob.bytes), + } + .map_err(|_| UNDECODED.to_string())?; if u64::from(w) * u64::from(h) > MAX_IMAGE_PIXELS { return Err("an image is too large for DXF and was left out".to_string()); }