mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-11-01 13:47:21 -06:00
Export: EPS, legacy .ai, EMF/WMF and DXF give one note for images that can't be decoded
EPS, EMF, WMF and DXF exports gave each image they left out because it couldn't be decoded its own warning, "image '<key>' could not be decoded and was left out", which names the internal key the document stores the image under. A version 7 .ai said "an image that can't be decoded or is too large was left out". The four writers now give the note raster exports, PDF and the legacy .ai flattening give, "an image couldn't be decoded and is missing from the picture", once per export. In a version 7 .ai it is one line with the note for flattened art. The other image notes in the same functions no longer name the key: EPS's note for an image too large to write, and DXF's notes for an image with no pixels (its rows in 23 catalogs are reworded) and one that could not be written. Legacy .ai gives a separate note for an image that is empty or too large. Docs: docs/mcp.md (EPS, DXF export, EMF and WMF, aiVersion "7").
This commit is contained in:
@@ -98,7 +98,10 @@ const STROKES: &str =
|
||||
"strokes a plain line can't draw (inside or outside the path, variable width, gradients, brushes, arrowheads) are written as filled outlines";
|
||||
const IMAGE_ALPHA: &str = "transparent image pixels are written over white";
|
||||
const LIVE: &str = "symbols, blends, envelopes, meshes, repeats, placed documents and intertwines are written as their art";
|
||||
const UNREADABLE_IMAGE: &str = "an image that can't be decoded or is too large was left out";
|
||||
/// The warning for an image left out because it can't be decoded: the note raster exports give
|
||||
/// (`vectorcraft-engine`'s `rasterfx::undecoded_warning`).
|
||||
const UNDECODED: &str = "an image couldn't be decoded and is missing from the picture";
|
||||
const LARGE_IMAGE: &str = "an image that is empty or too large for legacy .ai was left out";
|
||||
const ELLIPTICAL: &str = "elliptical radial gradients are written circular";
|
||||
|
||||
/// What to write in the header, and how to write what the format can't hold.
|
||||
@@ -1303,12 +1306,12 @@ impl<'a> Writer<'a> {
|
||||
return;
|
||||
}
|
||||
let Some(img) = self.doc.images.get(&im.key).and_then(|b| image::load_from_memory(&b.bytes).ok()) else {
|
||||
self.warn(UNREADABLE_IMAGE);
|
||||
self.warn(UNDECODED);
|
||||
return;
|
||||
};
|
||||
let (w, h) = (img.width(), img.height());
|
||||
if w == 0 || h == 0 || u64::from(w) * u64::from(h) > MAX_IMAGE_PIXELS {
|
||||
self.warn(UNREADABLE_IMAGE);
|
||||
self.warn(LARGE_IMAGE);
|
||||
return;
|
||||
}
|
||||
// The object places the image's own pixel grid (its width × height) wherever the file's is.
|
||||
|
||||
@@ -33,6 +33,10 @@ const TRANSPARENCY: &str =
|
||||
const RASTER_FX: &str = "raster effects (shadows, glows, blurs, feathering) are left out: EPS has no transparency, flatten them first";
|
||||
const IMAGE_ALPHA_L2: &str = "transparent image pixels are written white at PostScript Level 2 (Level 3 masks them out)";
|
||||
const IMAGE_PARTLY: &str = "partly transparent image pixels are written over white";
|
||||
/// The warning for an image left out because it can't be decoded: the note raster exports give
|
||||
/// (`vectorcraft-engine`'s `rasterfx::undecoded_warning`).
|
||||
const UNDECODED: &str = "an image couldn't be decoded and is missing from the picture";
|
||||
const LARGE_IMAGE: &str = "an image that is too large for EPS was left out";
|
||||
const SPOT_GRADIENTS: &str = "gradients of spot colours are written in process colours";
|
||||
const MISSING_PATTERN: &str = "missing patterns are written as mid-grey";
|
||||
|
||||
@@ -859,11 +863,11 @@ impl<'a> Scene<'a> {
|
||||
/// Image `key` as RGBA pixels; `None` (with a warning) when it can't be written.
|
||||
fn decode_image(&mut self, key: &str) -> Option<image::RgbaImage> {
|
||||
let Some(img) = self.doc.images.get(key).and_then(|blob| image::load_from_memory(&blob.bytes).ok()) else {
|
||||
self.warn(&format!("image '{key}' could not be decoded and was left out"));
|
||||
self.warn(UNDECODED);
|
||||
return None;
|
||||
};
|
||||
if u64::from(img.width()) * u64::from(img.height()) > MAX_IMAGE_PIXELS {
|
||||
self.warn(&format!("image '{key}' is too large for EPS and was left out"));
|
||||
self.warn(LARGE_IMAGE);
|
||||
return None;
|
||||
}
|
||||
Some(img.to_rgba8())
|
||||
|
||||
Reference in New Issue
Block a user