mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-11-17 14:14:50 +00:00
fix(codecs): read image sizes from headers for PNG, JPEG and TIFF again
craft_image_codecs::probe_size only reads WebP, EXR and the GIF/BMP/TGA family; for PNG, JPEG and TIFF it returns Unsupported. The cutover used it for header sizes, so DXF export left every PNG out (cad tests), plugin objects lost PNG pixels, and EPS image-mask and SVG import fell back to decoding whole images to learn their size. vectorcraft_doc::header_size reads PNG's IHDR and a JPEG's frame through craft-image-codecs and other formats through the image crate's header readers, as main does, without decoding pixels. The SVG filter's JPEG size comes from jpeg_info instead of a full decode.
This commit is contained in:
@@ -459,7 +459,7 @@ fn color_mode(b: &ImageBlob) -> &'static str {
|
||||
if b.gray_source().is_some() {
|
||||
return "gray";
|
||||
}
|
||||
let readable = craft_image_codecs::probe_size(&b.bytes).is_ok() || b.header_size().is_some();
|
||||
let readable = vectorcraft_doc::header_size(&b.bytes).is_some() || b.header_size().is_some();
|
||||
if readable { "rgb" } else { "unknown" }
|
||||
}
|
||||
|
||||
@@ -480,7 +480,7 @@ fn rgba_pixels(b: &ImageBlob, w: u32, h: u32, max: usize, charged: &mut usize) -
|
||||
return None;
|
||||
}
|
||||
let cmyk = b.is_cmyk();
|
||||
let size = if cmyk { b.header_size()? } else { craft_image_codecs::probe_size(&b.bytes).ok().or_else(|| b.header_size())? };
|
||||
let size = if cmyk { b.header_size()? } else { vectorcraft_doc::header_size(&b.bytes).or_else(|| b.header_size())? };
|
||||
if size != (w, h) {
|
||||
return None;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user