Document Info: Linked Images and Embedded Images show each image's format, resolution and memory

A Linked Images row now gives the image's format, its size in pixels, its
resolution at the size it is placed at and its file
(`PNG; 1200 × 800 px; 150 ppi — /art/photo.png`, both axes when they
differ, `resolution unavailable` when the transform leaves the image no
area). An Embedded Images row gives the format, the size and the estimated
memory of the 8-bit RGBA pixels the image is drawn from
(`PNG; 1200 × 800 px; estimated memory 3.7 MiB`). The format comes from a
linked file's extension, else from the type of the pixels the document
holds, and reads `Unknown format` when neither is known.

document.info's imageObjects entries gain format, effectivePpi,
memoryBytes and storedBytes (the encoded bytes an embedded image keeps).
The Document Info report and Package's report write the same rows, and the
panel shows them in the interface language, with the new templates in every
complete catalog.
This commit is contained in:
dotCooCoo committed 2026-11-20 21:05:34 -08:00
1 parent 1759064a3e
commit cd4ac68c09
34 files changed
+507 -29

No files matched your search

+3 -2
View File
@@ -845,8 +845,9 @@ pub(crate) const MAX_IMPORTED_PRESETS: usize = 1000;
pub(crate) use addons::{DecodedImages, refresh_color_masks};
/// Packaging Tools' blanks and the objects their print leaves out, for the Fold Preview window.
pub use addons::{fold_source, print_hidden};
/// Document Info's category titles and the Objects category's count labels.
pub use docinfo::{CATEGORIES, OBJECT_LABELS};
/// Document Info's category titles, the Objects category's count labels, and how its image rows
/// write a resolution and a number of bytes.
pub use docinfo::{CATEGORIES, OBJECT_LABELS, byte_size, ppi_number};
pub use docmenu::guide_indexes;
pub(crate) use edit::{Unrecorded, settle_interaction, typing_in_progress};
pub(crate) use object::bounds_rewrite;
+244 -17
View File
@@ -18,7 +18,7 @@ pub fn specs() -> Vec<CommandSpec> {
"Document Info",
["Window", "Document Info"],
None,
"{selectionOnly?, category?: document|objects|graphicStyles|brushes|spotColors|patterns|gradients|symbols|fonts|fontDetails|linkedImages|embeddedImages|repeats (only that one in sections and the text), format?: \"text\" (→ {text}: the report Document Info › Save… and Package write)} → {document: {…, units (English), unitId: the units' Preferences › Units id (points, millimeters, feetInches, …), rasterEffectsPpi, transparency: {gridSize: small|medium|large, gridColors: [#rrggbb, #rrggbb], gridColorsName (a preset's name or Custom), simulatePaper, flattenerPreset} (File › Document Setup's transparency settings, which the document category lists), selectedArtboards: [{index, name, width, height, x, y}] (while the Artboard tool is the current tool, the artboards it has selected, in the document's units, x and y those of the top-left corner from the ruler origin of its active artboard, which the document category lists after the artboards; else empty)}, objects: {paths, compoundPaths, groups, …}, pathLength: pt (the paths' total length, compound paths' included, guides left out), fonts (the type in opacity masks and in the art of symbols and patterns included; with selectionOnly: the selected type's), fontUses: [{font, type: truetype|opentype|unknown, uses}] (each font of fonts, in order: truetype or opentype by the outlines (glyf, or CFF or CFF2) of the face its type is drawn in, unknown for a font not installed in the family and style it names; uses: the text objects set in it, each once however many of its runs use the font, the type in a mask or in a symbol's or pattern's art once however many objects show it; the fonts category's rows give them as `TrueType; 2 uses`), fontDetails: [{font, match: exact|style|missingWithFallback|missing, family, style, file, embedding: allowed|editing|previewPrint|forbidden|null}] (each font of fonts, in order: how it was found, the face shown (null when none), that face's file name (null for a built-in face) and what its license allows), images, imageObjects: [{name, width, height, linked, file}] (the image objects in the order Linked Images and Embedded Images list them; file: what a linked image's row shows, null for an embedded one), swatches, graphicStyleNames (with selectionOnly: the styles the selected objects are linked to), brushNames (the brushes the art's drawn strokes use, each once; with selectionOnly: those the selected objects' strokes use), brushes: [{name, type: calligraphic|scatter|art|pattern|bristle|null}] (those brushes with their types; null: not in the Brushes panel), panelBrushNames (the Brushes panel's brushes), repeatObjects: [{id, name, type: radial|grid|mirror, instances, rows?, cols?}] (the Repeat objects, those in groups and other repeats included; with selectionOnly: those in the selection), spotObjects: [{id, name, spotColors}] (the objects filled or stroked with a spot color swatch, as a solid color or in the stops of a gradient that color a part of it above opacity 0 (a stop at opacity 0 counts only where it mixes with a stop above opacity 0 over a stretch of some width), at a tint above 0, and grayscale images colorized with one, each once, by the rules patternObjects follows, with the spot colors they use; Registration and process colors are not spot colors; objects.spots counts them), spotColorNames and spotColors (the spot colors those objects use), patternObjects: [{id, name, patterns}] (the objects filled or stroked with a pattern, each once, those in groups and type whose drawn characters use one included, hidden fills and strokes, fills and strokes at an opacity of 0, strokes with no width, guides, compound path members' own fills and strokes, images' fills and strokes without a shape and characters that draw nothing left out, with the patterns they use, which objects.patterns counts; with selectionOnly: those in the selection), patternNames (the patterns those objects use), gradientObjects: [{id, name, gradients, kinds}] (the objects filled or stroked with a gradient, by the same rules, with the gradients they use: a linked gradient swatch's name, else its kind's name, such as Linear gradient; kinds gives each one's kind, linear|radial|conic|diamond|freeform, when it is named by its kind, else null; objects.gradients counts them), gradientNames (the gradients those objects use), …, sections: [{id, title, rows: [[label, value]]}] (the panel's categories; fontDetails: each font's file and whether its license lets it be embedded)}. An image linked to a file outside the automation read roots has link null, and its Linked Images row names the file alone. brushNames, brushes, spotObjects, patternObjects and gradientObjects leave out hidden objects, objects at an opacity of 0 and the objects inside a hidden group or layer or one at an opacity of 0 (with selectionOnly too), their characters' paints and colorized images included; objects still counts them as paths, groups and the other kinds",
"{selectionOnly?, category?: document|objects|graphicStyles|brushes|spotColors|patterns|gradients|symbols|fonts|fontDetails|linkedImages|embeddedImages|repeats (only that one in sections and the text), format?: \"text\" (→ {text}: the report Document Info › Save… and Package write)} → {document: {…, units (English), unitId: the units' Preferences › Units id (points, millimeters, feetInches, …), rasterEffectsPpi, transparency: {gridSize: small|medium|large, gridColors: [#rrggbb, #rrggbb], gridColorsName (a preset's name or Custom), simulatePaper, flattenerPreset} (File › Document Setup's transparency settings, which the document category lists), selectedArtboards: [{index, name, width, height, x, y}] (while the Artboard tool is the current tool, the artboards it has selected, in the document's units, x and y those of the top-left corner from the ruler origin of its active artboard, which the document category lists after the artboards; else empty)}, objects: {paths, compoundPaths, groups, …}, pathLength: pt (the paths' total length, compound paths' included, guides left out), fonts (the type in opacity masks and in the art of symbols and patterns included; with selectionOnly: the selected type's), fontUses: [{font, type: truetype|opentype|unknown, uses}] (each font of fonts, in order: truetype or opentype by the outlines (glyf, or CFF or CFF2) of the face its type is drawn in, unknown for a font not installed in the family and style it names; uses: the text objects set in it, each once however many of its runs use the font, the type in a mask or in a symbol's or pattern's art once however many objects show it; the fonts category's rows give them as `TrueType; 2 uses`), fontDetails: [{font, match: exact|style|missingWithFallback|missing, family, style, file, embedding: allowed|editing|previewPrint|forbidden|null}] (each font of fonts, in order: how it was found, the face shown (null when none), that face's file name (null for a built-in face) and what its license allows), images, imageObjects: [{name, width, height, linked, file, format, effectivePpi, memoryBytes, storedBytes}] (the image objects in the order Linked Images and Embedded Images list them; file: what a linked image's row shows, null for an embedded one; format: a linked image's file format by its extension, else the format of the pixels the document holds, null when unknown; effectivePpi: [x, y] pixels per inch at the size it is placed at, a distorted image measured at its middle, null when it has no area; memoryBytes: for an embedded image width × height × 4, the bytes of the 8-bit RGBA pixels it is drawn from, else null; storedBytes: for an embedded image the bytes of the encoded image the document holds, else null; a Linked Images row gives the format, the size, the resolution and the file (`PNG; 1200 × 800 px; 150 ppi — /art/photo.png`), an Embedded Images row the format, the size and the memory (`PNG; 1200 × 800 px; estimated memory 3.7 MiB`)), swatches, graphicStyleNames (with selectionOnly: the styles the selected objects are linked to), brushNames (the brushes the art's drawn strokes use, each once; with selectionOnly: those the selected objects' strokes use), brushes: [{name, type: calligraphic|scatter|art|pattern|bristle|null}] (those brushes with their types; null: not in the Brushes panel), panelBrushNames (the Brushes panel's brushes), repeatObjects: [{id, name, type: radial|grid|mirror, instances, rows?, cols?}] (the Repeat objects, those in groups and other repeats included; with selectionOnly: those in the selection), spotObjects: [{id, name, spotColors}] (the objects filled or stroked with a spot color swatch, as a solid color or in the stops of a gradient that color a part of it above opacity 0 (a stop at opacity 0 counts only where it mixes with a stop above opacity 0 over a stretch of some width), at a tint above 0, and grayscale images colorized with one, each once, by the rules patternObjects follows, with the spot colors they use; Registration and process colors are not spot colors; objects.spots counts them), spotColorNames and spotColors (the spot colors those objects use), patternObjects: [{id, name, patterns}] (the objects filled or stroked with a pattern, each once, those in groups and type whose drawn characters use one included, hidden fills and strokes, fills and strokes at an opacity of 0, strokes with no width, guides, compound path members' own fills and strokes, images' fills and strokes without a shape and characters that draw nothing left out, with the patterns they use, which objects.patterns counts; with selectionOnly: those in the selection), patternNames (the patterns those objects use), gradientObjects: [{id, name, gradients, kinds}] (the objects filled or stroked with a gradient, by the same rules, with the gradients they use: a linked gradient swatch's name, else its kind's name, such as Linear gradient; kinds gives each one's kind, linear|radial|conic|diamond|freef Line truncated
has_doc,
info
),
@@ -183,8 +183,123 @@ fn count_fonts(fonts: &mut BTreeMap<super::fonts::UsedFont, usize>, t: &vectorcr
}
}
/// An image object as Document Info lists it: (name, width, height, linked file).
type ImageRow = (String, u32, u32, Option<String>);
/// An image object as Linked Images or Embedded Images lists it.
struct ImageRow {
name: String,
width: u32,
height: u32,
/// What a linked image's row names: its file's path, or the file's name alone when the request
/// may not read it. `None` for an embedded image.
file: Option<String>,
/// The image's format ([`image_format`]); `None` when it is not known.
format: Option<&'static str>,
/// The pixels per inch across and down at the size the image is placed at; `None` when its
/// transform flattens it.
ppi: Option<[f64; 2]>,
/// For an embedded image, the bytes its pixels take when drawn (8-bit RGBA: width × height × 4).
memory: Option<u64>,
/// For an embedded image, the bytes of the encoded image the document holds.
stored: Option<u64>,
}
impl ImageRow {
/// Image object `n` (image `im`) of `d`, `file` the row value of its link.
fn of(d: &Document, n: &Node, im: &vectorcraft_doc::ImageObject, file: Option<String>) -> Self {
let name = im.link.as_ref().map_or_else(|| n.display_name(), |l| l.name().to_string());
// A distorted image is measured at its middle, as `image.info` measures it.
let xf = vectorcraft_doc::image_quad::nearest_affine(n).unwrap_or(im.xf);
let ppi = super::place::effective_ppi(xf);
// A transform that lays both pixel axes on one line leaves the image no area.
let has_area = xf.determinant().abs() > 1e-12;
let embedded = im.link.is_none();
let memory = || u64::from(im.width).checked_mul(u64::from(im.height))?.checked_mul(4);
Self {
name,
width: im.width,
height: im.height,
file,
format: image_format(d, im),
ppi: (has_area && ppi.iter().all(|v| *v > 0.0 && v.is_finite())).then_some(ppi),
memory: if embedded { memory() } else { None },
stored: if embedded { d.images.get(&im.key).map(|b| b.bytes.len() as u64) } else { None },
}
}
/// The row's value: the format, the size in pixels, and for a linked image its resolution and
/// file, for an embedded one the memory its pixels take.
fn value(&self) -> String {
let format = self.format.unwrap_or("Unknown format");
let size = format!("{} × {} px", self.width, self.height);
match &self.file {
Some(file) => {
let ppi = match self.ppi {
Some([x, y]) if ppi_number(x) == ppi_number(y) => format!("{} ppi", ppi_number(x)),
Some([x, y]) => format!("{} × {} ppi", ppi_number(x), ppi_number(y)),
None => "resolution unavailable".into(),
};
format!("{format}; {size}; {ppi} — {file}")
}
None => {
let memory = self.memory.map_or_else(|| "memory unavailable".to_string(), |b| format!("estimated memory {}", byte_size(b)));
format!("{format}; {size}; {memory}")
}
}
}
/// The row's `imageObjects` entry.
fn entry(&self) -> Value {
json!({
"name": self.name,
"width": self.width,
"height": self.height,
"linked": self.file.is_some(),
"file": self.file,
"format": self.format,
"effectivePpi": self.ppi,
"memoryBytes": self.memory,
"storedBytes": self.stored,
})
}
}
/// The format of image `im` of `d`, as the Links panel names it: for a linked image its file's, by
/// its extension (DCS for a separated one), else the type of the pixels the document holds for it;
/// `None` when neither names a known format.
fn image_format(d: &Document, im: &vectorcraft_doc::ImageObject) -> Option<&'static str> {
use super::fileio;
if im.link.is_some() && d.images.get(&im.key).is_some_and(vectorcraft_doc::ImageBlob::is_separated) {
return Some("DCS");
}
im.link
.as_ref()
.and_then(|l| fileio::format_for_name(l.name()).or_else(|| fileio::readable_format_for_name(l.name())))
.or_else(|| d.images.get(&im.key).and_then(|b| fileio::FORMATS.iter().find(|f| f.raster && f.mime == b.mime)))
.map(|f| f.label)
}
/// A resolution as Document Info shows it: rounded to a tenth (below 1, to a hundredth), without a
/// trailing `.0`.
pub fn ppi_number(ppi: f64) -> String {
let k = if ppi.abs() < 1.0 { 100.0 } else { 10.0 };
format!("{}", (ppi * k).round() / k)
}
/// A number of bytes as Document Info shows it: in B below 1 KiB, else in KiB, MiB or GiB rounded
/// to a tenth.
pub fn byte_size(bytes: u64) -> String {
const UNITS: [&str; 3] = ["KiB", "MiB", "GiB"];
if bytes < 1024 {
return format!("{bytes} B");
}
let mut v = bytes as f64 / 1024.0;
let mut unit = 0;
// 1023.96 KiB is shown as 1 MiB rather than as 1024 KiB.
while v >= 1023.95 && unit + 1 < UNITS.len() {
v /= 1024.0;
unit += 1;
}
format!("{} {}", (v * 10.0).round() / 10.0, UNITS[unit])
}
/// A Repeat object as Document Info lists it: its `repeatObjects` entry, and its row, which gives
/// its name and then its kind with the number of instances it draws (for a grid, its rows and
@@ -337,11 +452,9 @@ fn sections(
"symbols" => names("symbols"),
"fonts" => fonts.to_vec(),
"fontDetails" => font_details.to_vec(),
"linkedImages" => {
images.iter().filter_map(|(name, w, h, link)| Some((name.clone(), format!("{w} × {h} px — {}", link.as_ref()?)))).collect()
}
"linkedImages" => images.iter().filter(|i| i.file.is_some()).map(|i| (i.name.clone(), i.value())).collect(),
"repeats" => repeats.to_vec(),
_ => images.iter().filter(|i| i.3.is_none()).map(|(name, w, h, _)| (name.clone(), format!("{w} × {h} px"))).collect(),
_ => images.iter().filter(|i| i.file.is_none()).map(|i| (i.name.clone(), i.value())).collect(),
};
Section { id, title, rows }
})
@@ -753,8 +866,8 @@ fn info(s: &mut Session, p: &Value) -> Result<Value> {
im.key.clone(),
json!({ "width": im.width, "height": im.height, "linked": im.link.is_some(), "link": link.and_then(|(l, ok)| ok.then_some(&l.path)) }),
);
let name = im.link.as_ref().map_or_else(|| n.display_name(), |l| l.name().to_string());
image_rows.push((name, im.width, im.height, link.map(|(l, ok)| if ok { l.path.clone() } else { l.name().to_string() })));
let file = link.map(|(l, ok)| if ok { l.path.clone() } else { l.name().to_string() });
image_rows.push(ImageRow::of(d, n, im, file));
Some("images")
}
NodeKind::SymbolInstance { symbol, .. } => {
@@ -835,13 +948,8 @@ fn info(s: &mut Session, p: &Value) -> Result<Value> {
let font_names: Vec<String> = fonts.keys().map(super::fonts::font_label).collect();
let (font_uses, font_use_rows): (Vec<Value>, Vec<(String, String)>) = fonts.iter().map(|(f, n)| font_use(f, *n)).unzip();
let (font_entries, font_rows): (Vec<Value>, Vec<(String, String)>) = fonts.keys().map(font_detail).unzip();
// The image objects in walk order, as Linked Images and Embedded Images list them: `file` is a
// linked image's row value (its path, or its file name alone when the request may not read it),
// and null for an embedded one.
let image_objects: Vec<Value> = image_rows
.iter()
.map(|(name, w, h, file)| json!({ "name": name, "width": w, "height": h, "linked": file.is_some(), "file": file }))
.collect();
// The image objects in walk order, as Linked Images and Embedded Images list them.
let image_objects: Vec<Value> = image_rows.iter().map(ImageRow::entry).collect();
// Each brush the art uses with its type, found by name in the Brushes panel as the renderer finds it (the first of two
// brushes with one name); a brush the panel does not hold draws as a plain stroke and has no type. A row names the type
// as the New Brush dialog does (`Art Brush`), and the panel translates these values when it shows them.
@@ -2246,11 +2354,130 @@ mod tests {
assert_eq!(objects.len(), 2, "{objects:?}");
for (o, r) in objects.iter().zip(&embedded) {
assert_eq!((o["linked"].clone(), o["file"].clone(), o["name"].clone()), (json!(false), Value::Null, r[0].clone()), "{o}");
assert_eq!(r[1], format!("{} × {} px", o["width"], o["height"]));
let memory = byte_size(o["memoryBytes"].as_u64().unwrap());
assert_eq!(r[1], format!("{}; {} × {} px; estimated memory {memory}", o["format"].as_str().unwrap(), o["width"], o["height"]));
}
assert!(section("linkedImages").is_empty());
}
/// An image object to place: (key, MIME type, linked path, width, height, transform).
type Placed<'a> = (&'a str, &'a str, Option<&'a str>, u32, u32, Affine);
/// Image objects `images` placed in a new document, with a blob of `100 + n` bytes of type
/// `mime` for each new key; their ids in order.
fn images_in(s: &mut Session, images: &[Placed]) -> Vec<NodeId> {
s.execute("file.new", &json!({"width": 400, "height": 400})).unwrap();
s.edit("Place", |d, _| {
let mut ids = vec![];
for (n, (key, mime, link, width, height, xf)) in images.iter().enumerate() {
if !d.images.contains_key(*key) {
d.images.insert((*key).into(), vectorcraft_doc::ImageBlob::new(*mime, vec![0; 100 + n]));
}
let id = d.alloc_id();
let im = vectorcraft_doc::ImageObject {
key: (*key).into(),
width: *width,
height: *height,
xf: *xf,
link: link.map(vectorcraft_doc::LinkInfo::new),
placement: Default::default(),
pixels: None,
};
d.insert(d.default_layer(), usize::MAX, Node::new(id, NodeKind::Image(Box::new(im))))?;
ids.push(id);
}
Ok(ids)
})
.unwrap()
}
/// Linked Images gives each linked image's format, size in pixels, resolution at the size it is
/// placed at and file, and Embedded Images each embedded image's format, size and the memory
/// its pixels take; `imageObjects` gives the same facts with the bytes the document holds for an
/// embedded image, the text report writes the same rows, and Selection Only lists the selected
/// images alone.
#[test]
fn image_rows_give_format_resolution_and_memory() {
let mut s = Session::new();
let half = Affine::scale(0.5);
let ids = images_in(
&mut s,
&[
("a", "image/png", None, 1200, 800, half),
("b", "image/jpeg", None, 10, 10, half),
("c", "image/x-unheard-of", None, 3, 2, half),
("a", "image/png", Some("/art/photo.png"), 1200, 800, Affine::scale(0.48)),
("a", "image/png", Some("/art/photo.png"), 1200, 800, Affine::scale(0.24)),
("a", "image/png", Some("/art/wide.png"), 1200, 800, Affine::scale_non_uniform(0.5, 1.0)),
("a", "image/png", Some("/art/scan.tif"), 1200, 800, half),
("a", "image/png", Some("/art/flat.png"), 1200, 800, Affine::scale_non_uniform(0.5, 0.0)),
// Both pixel axes on one line: neither has length 0, but the image has no area.
("a", "image/png", Some("/art/line.png"), 1200, 800, Affine::new([0.5, 0.5, 1.0, 1.0, 0.0, 0.0])),
("c", "image/x-unheard-of", Some("/art/odd.qqq"), 3, 2, half),
],
);
let i = s.execute("document.info", &json!({})).unwrap();
let rows = |i: &Value, id: &str| -> Vec<(String, String)> {
let section = i["sections"].as_array().unwrap().iter().find(|s| s["id"] == id).unwrap().clone();
section["rows"].as_array().unwrap().iter().map(|r| (r[0].as_str().unwrap().into(), r[1].as_str().unwrap().into())).collect()
};
let embedded = rows(&i, "embeddedImages");
let values: Vec<&str> = embedded.iter().map(|(_, v)| v.as_str()).collect();
assert_eq!(
values,
[
"PNG; 1200 × 800 px; estimated memory 3.7 MiB",
"JPEG; 10 × 10 px; estimated memory 400 B",
"Unknown format; 3 × 2 px; estimated memory 24 B"
]
);
let linked = rows(&i, "linkedImages");
assert_eq!(
linked,
[
("photo.png", "PNG; 1200 × 800 px; 150 ppi — /art/photo.png"),
("photo.png", "PNG; 1200 × 800 px; 300 ppi — /art/photo.png"),
("wide.png", "PNG; 1200 × 800 px; 144 × 72 ppi — /art/wide.png"),
("scan.tif", "TIFF; 1200 × 800 px; 144 ppi — /art/scan.tif"),
("flat.png", "PNG; 1200 × 800 px; resolution unavailable — /art/flat.png"),
("line.png", "PNG; 1200 × 800 px; resolution unavailable — /art/line.png"),
("odd.qqq", "Unknown format; 3 × 2 px; 144 ppi — /art/odd.qqq"),
]
.map(|(a, b)| (a.to_string(), b.to_string()))
);
let objects = i["imageObjects"].as_array().unwrap();
assert_eq!(objects.len(), 10);
assert_eq!(
(objects[0]["format"].clone(), objects[0]["effectivePpi"].clone(), objects[0]["memoryBytes"].clone(), objects[0]["storedBytes"].clone()),
(json!("PNG"), json!([144.0, 144.0]), json!(1200 * 800 * 4), json!(100))
);
assert_eq!((objects[1]["format"].clone(), objects[1]["storedBytes"].clone()), (json!("JPEG"), json!(101)));
assert_eq!(objects[2]["format"], Value::Null);
// A linked image gives no memory and no stored bytes: the document holds only its preview.
assert_eq!((objects[3]["memoryBytes"].clone(), objects[3]["storedBytes"].clone()), (Value::Null, Value::Null));
let ppi = |o: &Value| -> Vec<f64> { o["effectivePpi"].as_array().unwrap().iter().map(|v| v.as_f64().unwrap()).collect() };
assert!(ppi(&objects[3]).iter().all(|v| (v - 150.0).abs() < 1e-9), "{}", objects[3]);
assert_eq!(ppi(&objects[5]), [144.0, 72.0]);
assert_eq!((objects[7]["effectivePpi"].clone(), objects[8]["effectivePpi"].clone()), (Value::Null, Value::Null));
let text = s.execute("document.info", &json!({"format": "text"})).unwrap()["text"].as_str().unwrap().to_string();
assert!(text.contains("\nphoto.png: PNG; 1200 × 800 px; 150 ppi — /art/photo.png\n"), "{text}");
assert!(text.contains(": JPEG; 10 × 10 px; estimated memory 400 B\n"), "{text}");
// Selection Only lists the selected images alone, with the same rows.
s.execute("select.set", &json!({"ids": [ids[1].0, ids[5].0]})).unwrap();
let selected = s.execute("document.info", &json!({"selectionOnly": true})).unwrap();
assert_eq!(rows(&selected, "embeddedImages").iter().map(|(_, v)| v.as_str()).collect::<Vec<_>>(), [values[1]]);
assert_eq!(rows(&selected, "linkedImages"), [linked[2].clone()]);
}
/// A number of bytes reads in B below 1 KiB, else in KiB, MiB or GiB to a tenth, and a
/// resolution to a tenth without a trailing `.0`.
#[test]
fn byte_sizes_and_resolutions_read_to_a_tenth() {
let shown = [0, 1023, 1024, 1536, 1024 * 1024 - 1, 3_840_000, 5 << 30, u64::MAX].map(byte_size);
assert_eq!(shown, ["0 B", "1023 B", "1 KiB", "1.5 KiB", "1 MiB", "3.7 MiB", "5 GiB", "17179869184 GiB"]);
assert_eq!([150.0, 72.0 / 0.48, 205.714, 0.04, 0.001].map(ppi_number), ["150", "150", "205.7", "0.04", "0"]);
}
/// A `gradientObjects` entry's `kinds` gives the kind of each gradient listed by its kind
/// rather than by a swatch, and null for a swatch's name, even one that reads like a kind and
/// one an object's gradient of that kind shares; a type object's characters count as its own.
+6
View File
@@ -2384,6 +2384,12 @@ font-technology Variable Променливи
{width} × {height} px {width} × {height} px
{size} — {file} {size} — {file}
{n} ppi {n} ppi
{format}; {size}; {detail} {format}; {size}; {detail}
{x} × {y} ppi {x} × {y} ppi
resolution unavailable разделителната способност не е налична
estimated memory {memory} приблизителна памет {memory}
memory unavailable паметта не е налична
Unknown format Неизвестен формат
{kind}, {instances} {kind}, {instances}
{kind}, {rows} × {cols} {kind}, {rows} × {cols}
{grid}, {instances} {grid}, {instances}
Can't render this file because it is too large.
+6
View File
@@ -3676,6 +3676,12 @@ theme Appearance Izgled
{width} × {height} px {width} × {height} px
{size} — {file} {size} — {file}
{n} ppi {n} ppi
{format}; {size}; {detail} {format}; {size}; {detail}
{x} × {y} ppi {x} × {y} ppi
resolution unavailable rezolucija nije dostupna
estimated memory {memory} procijenjena memorija {memory}
memory unavailable memorija nije dostupna
Unknown format Nepoznat format
{kind}, {instances} {kind}, {instances}
{kind}, {rows} × {cols} {kind}, {rows} × {cols}
{grid}, {instances} {grid}, {instances}
Can't render this file because it contains an unexpected character in line 2 and column 73.
+6
View File
@@ -3434,6 +3434,12 @@ digits Malayalam Malaiàlam
{width} × {height} px {width} × {height} px
{size} — {file} {size} — {file}
{n} ppi {n} ppp
{format}; {size}; {detail} {format}; {size}; {detail}
{x} × {y} ppi {x} × {y} ppp
resolution unavailable resolució no disponible
estimated memory {memory} memòria estimada {memory}
memory unavailable memòria no disponible
Unknown format Format desconegut
{kind}, {instances} {kind}, {instances}
{kind}, {rows} × {cols} {kind}, {rows} × {cols}
{grid}, {instances} {grid}, {instances}
Can't render this file because it is too large.
+6
View File
@@ -3777,6 +3777,12 @@ theme Appearance Motiv
{width} × {height} px {width} × {height} px
{size} — {file} {size} – {file}
{n} ppi {n} ppi
{format}; {size}; {detail} {format}; {size}; {detail}
{x} × {y} ppi {x} × {y} ppi
resolution unavailable rozlišení není k dispozici
estimated memory {memory} odhadovaná paměť {memory}
memory unavailable paměť není k dispozici
Unknown format Neznámý formát
{kind}, {instances} {kind}, {instances}
{kind}, {rows} × {cols} {kind}, {rows} × {cols}
{grid}, {instances} {grid}, {instances}
Can't render this file because it is too large.
+6
View File
@@ -6257,6 +6257,12 @@ theme Appearance Udseende
{width} × {height} px {width} × {height} px
{size} — {file} {size} – {file}
{n} ppi {n} ppi
{format}; {size}; {detail} {format}; {size}; {detail}
{x} × {y} ppi {x} × {y} ppi
resolution unavailable opløsning ikke tilgængelig
estimated memory {memory} anslået hukommelse {memory}
memory unavailable hukommelse ikke tilgængelig
Unknown format Ukendt format
{kind}, {instances} {kind}, {instances}
{kind}, {rows} × {cols} {kind}, {rows} × {cols}
{grid}, {instances} {grid}, {instances}
Can't render this file because it is too large.
+6
View File
@@ -2435,6 +2435,12 @@ file-filter Templates Vorlagen
{width} × {height} px {width} × {height} px
{size} — {file} {size} – {file}
{n} ppi {n} ppi
{format}; {size}; {detail} {format}; {size}; {detail}
{x} × {y} ppi {x} × {y} ppi
resolution unavailable Auflösung nicht verfügbar
estimated memory {memory} geschätzter Speicher {memory}
memory unavailable Speicher nicht verfügbar
Unknown format Unbekanntes Format
{kind}, {instances} {kind}, {instances}
{kind}, {rows} × {cols} {kind}, {rows} × {cols}
{grid}, {instances} {grid}, {instances}
Can't render this file because it is too large.
+6
View File
@@ -2088,6 +2088,12 @@ font-technology Variable Μεταβλητές
{width} × {height} px {width} × {height} px
{size} — {file} {size} — {file}
{n} ppi {n} ppi
{format}; {size}; {detail} {format}· {size}· {detail}
{x} × {y} ppi {x} × {y} ppi
resolution unavailable η ανάλυση δεν είναι διαθέσιμη
estimated memory {memory} εκτιμώμενη μνήμη {memory}
memory unavailable η μνήμη δεν είναι διαθέσιμη
Unknown format Άγνωστη μορφή
{kind}, {instances} {kind}, {instances}
{kind}, {rows} × {cols} {kind}, {rows} × {cols}
{grid}, {instances} {grid}, {instances}
Can't render this file because it is too large.
+6
View File
@@ -2478,6 +2478,12 @@ font-technology Variable Variables
{width} × {height} px {width} × {height} px
{size} — {file} {size} — {file}
{n} ppi {n} ppp
{format}; {size}; {detail} {format}; {size}; {detail}
{x} × {y} ppi {x} × {y} ppp
resolution unavailable resolución no disponible
estimated memory {memory} memoria estimada {memory}
memory unavailable memoria no disponible
Unknown format Formato desconocido
{kind}, {instances} {kind}, {instances}
{kind}, {rows} × {cols} {kind}, {rows} × {cols}
{grid}, {instances} {grid}, {instances}
Can't render this file because it is too large.
+6
View File
@@ -3714,6 +3714,12 @@ theme Appearance Ulkoasu
{width} × {height} px {width} × {height} px
{size} — {file} {size} – {file}
{n} ppi {n} ppi
{format}; {size}; {detail} {format}; {size}; {detail}
{x} × {y} ppi {x} × {y} ppi
resolution unavailable tarkkuus ei saatavilla
estimated memory {memory} arvioitu muisti {memory}
memory unavailable muisti ei saatavilla
Unknown format Tuntematon muoto
{kind}, {instances} {kind}, {instances}
{kind}, {rows} × {cols} {kind}, {rows} × {cols}
{grid}, {instances} {grid}, {instances}
Can't render this file because it is too large.
+6
View File
@@ -2466,6 +2466,12 @@ font-technology Variable Variables
{width} × {height} px {width} × {height} px
{size} — {file} {size} — {file}
{n} ppi {n} ppp
{format}; {size}; {detail} {format}, {size}, {detail}
{x} × {y} ppi {x} × {y} ppp
resolution unavailable résolution indisponible
estimated memory {memory} mémoire estimée {memory}
memory unavailable mémoire indisponible
Unknown format Format inconnu
{kind}, {instances} {kind}, {instances}
{kind}, {rows} × {cols} {kind}, {rows} × {cols}
{grid}, {instances} {grid}, {instances}
Can't render this file because it is too large.
+6
View File
@@ -5205,6 +5205,12 @@ antiAlias Sharp શાર્પ
{width} × {height} px {width} × {height} px
{size} — {file} {size} — {file}
{n} ppi {n} ppi
{format}; {size}; {detail} {format}; {size}; {detail}
{x} × {y} ppi {x} × {y} ppi
resolution unavailable રિઝોલ્યુશન ઉપલબ્ધ નથી
estimated memory {memory} અંદાજિત મેમરી {memory}
memory unavailable મેમરી ઉપલબ્ધ નથી
Unknown format અજ્ઞાત ફોર્મેટ
{kind}, {instances} {kind}, {instances}
{kind}, {rows} × {cols} {kind}, {rows} × {cols}
{grid}, {instances} {grid}, {instances}
Can't render this file because it contains an unexpected character in line 72 and column 5.
+6
View File
@@ -3979,6 +3979,12 @@ arrowhead Feather पंख
{width} × {height} px {width} × {height} px
{size} — {file} {size} — {file}
{n} ppi {n} ppi
{format}; {size}; {detail} {format}; {size}; {detail}
{x} × {y} ppi {x} × {y} ppi
resolution unavailable रिज़ॉल्यूशन उपलब्ध नहीं
estimated memory {memory} अनुमानित मेमोरी {memory}
memory unavailable मेमोरी उपलब्ध नहीं
Unknown format अज्ञात फ़ॉर्मेट
{kind}, {instances} {kind}, {instances}
{kind}, {rows} × {cols} {kind}, {rows} × {cols}
{grid}, {instances} {grid}, {instances}
Can't render this file because it is too large.
+6
View File
@@ -3316,6 +3316,12 @@ file-filter Templates Sablonok
{width} × {height} px {width} × {height} px
{size} — {file} {size} – {file}
{n} ppi {n} ppi
{format}; {size}; {detail} {format}; {size}; {detail}
{x} × {y} ppi {x} × {y} ppi
resolution unavailable a felbontás nem érhető el
estimated memory {memory} becsült memória {memory}
memory unavailable a memória nem érhető el
Unknown format Ismeretlen formátum
{kind}, {instances} {kind}, {instances}
{kind}, {rows} × {cols} {kind}, {rows} × {cols}
{grid}, {instances} {grid}, {instances}
Can't render this file because it is too large.
+6
View File
@@ -4125,6 +4125,12 @@ theme Appearance Tampilan
{width} × {height} px {width} × {height} px
{size} — {file} {size} — {file}
{n} ppi {n} ppi
{format}; {size}; {detail} {format}; {size}; {detail}
{x} × {y} ppi {x} × {y} ppi
resolution unavailable resolusi tidak tersedia
estimated memory {memory} perkiraan memori {memory}
memory unavailable memori tidak tersedia
Unknown format Format tidak dikenal
{kind}, {instances} {kind}, {instances}
{kind}, {rows} × {cols} {kind}, {rows} × {cols}
{grid}, {instances} {grid}, {instances}
Can't render this file because it is too large.
+6
View File
@@ -2520,6 +2520,12 @@ file-filter Templates Modelli
{width} × {height} px {width} × {height} px
{size} — {file} {size} — {file}
{n} ppi {n} ppi
{format}; {size}; {detail} {format}; {size}; {detail}
{x} × {y} ppi {x} × {y} ppi
resolution unavailable risoluzione non disponibile
estimated memory {memory} memoria stimata {memory}
memory unavailable memoria non disponibile
Unknown format Formato sconosciuto
{kind}, {instances} {kind}, {instances}
{kind}, {rows} × {cols} {kind}, {rows} × {cols}
{grid}, {instances} {grid}, {instances}
Can't render this file because it is too large.
+6
View File
@@ -2703,6 +2703,12 @@ antiAlias Sharp シャープ
{width} × {height} px {width} × {height} px
{size} — {file} {size} — {file}
{n} ppi {n} ppi
{format}; {size}; {detail} {format}、{size}、{detail}
{x} × {y} ppi {x} × {y} ppi
resolution unavailable 解像度を取得できません
estimated memory {memory} 推定メモリ {memory}
memory unavailable メモリを取得できません
Unknown format 不明な形式
{kind}, {instances} {kind}、{instances}
{kind}, {rows} × {cols} {kind}、{rows} × {cols}
{grid}, {instances} {grid}、{instances}
Can't render this file because it is too large.
+6
View File
@@ -5535,6 +5535,12 @@ theme Appearance იერსახე
{width} × {height} px {width} × {height} px
{size} — {file} {size} — {file}
{n} ppi {n} ppi
{format}; {size}; {detail} {format}; {size}; {detail}
{x} × {y} ppi {x} × {y} ppi
resolution unavailable გარჩევადობა მიუწვდომელია
estimated memory {memory} სავარაუდო მეხსიერება {memory}
memory unavailable მეხსიერება მიუწვდომელია
Unknown format უცნობი ფორმატი
{kind}, {instances} {kind}, {instances}
{kind}, {rows} × {cols} {kind}, {rows} × {cols}
{grid}, {instances} {grid}, {instances}
Can't render this file because it is too large.
+6
View File
@@ -2693,6 +2693,12 @@ antiAlias Sharp 날카롭게
{width} × {height} px {width} × {height} px
{size} — {file} {size} — {file}
{n} ppi {n} ppi
{format}; {size}; {detail} {format}; {size}; {detail}
{x} × {y} ppi {x} × {y} ppi
resolution unavailable 해상도를 알 수 없음
estimated memory {memory} 예상 메모리 {memory}
memory unavailable 메모리를 알 수 없음
Unknown format 알 수 없는 형식
{kind}, {instances} {kind}, {instances}
{kind}, {rows} × {cols} {kind}, {rows} × {cols}
{grid}, {instances} {grid}, {instances}
Can't render this file because it is too large.
+6
View File
@@ -4123,6 +4123,12 @@ theme Appearance Vormgeving
{width} × {height} px {width} × {height} px
{size} — {file} {size} – {file}
{n} ppi {n} ppi
{format}; {size}; {detail} {format}; {size}; {detail}
{x} × {y} ppi {x} × {y} ppi
resolution unavailable resolutie niet beschikbaar
estimated memory {memory} geschat geheugen {memory}
memory unavailable geheugen niet beschikbaar
Unknown format Onbekend formaat
{kind}, {instances} {kind}, {instances}
{kind}, {rows} × {cols} {kind}, {rows} × {cols}
{grid}, {instances} {grid}, {instances}
Can't render this file because it is too large.
+6
View File
@@ -3656,6 +3656,12 @@ theme Appearance Wygląd
{width} × {height} px {width} × {height} px
{size} — {file} {size} – {file}
{n} ppi {n} ppi
{format}; {size}; {detail} {format}; {size}; {detail}
{x} × {y} ppi {x} × {y} ppi
resolution unavailable rozdzielczość niedostępna
estimated memory {memory} szacowana pamięć {memory}
memory unavailable pamięć niedostępna
Unknown format Nieznany format
{kind}, {instances} {kind}, {instances}
{kind}, {rows} × {cols} {kind}, {rows} × {cols}
{grid}, {instances} {grid}, {instances}
Can't render this file because it is too large.
+6
View File
@@ -2015,6 +2015,12 @@ antiAlias Sharp Nítido
{width} × {height} px {width} × {height} px
{size} — {file} {size} — {file}
{n} ppi {n} ppp
{format}; {size}; {detail} {format}; {size}; {detail}
{x} × {y} ppi {x} × {y} ppp
resolution unavailable resolução indisponível
estimated memory {memory} memória estimada {memory}
memory unavailable memória indisponível
Unknown format Formato desconhecido
{kind}, {instances} {kind}, {instances}
{kind}, {rows} × {cols} {kind}, {rows} × {cols}
{grid}, {instances} {grid}, {instances}
Can't render this file because it is too large.
+6
View File
@@ -2504,6 +2504,12 @@ file-filter Templates Шаблоны
{width} × {height} px {width} × {height} px
{size} — {file} {size} — {file}
{n} ppi {n} ppi
{format}; {size}; {detail} {format}; {size}; {detail}
{x} × {y} ppi {x} × {y} ppi
resolution unavailable разрешение недоступно
estimated memory {memory} оценка памяти {memory}
memory unavailable память недоступна
Unknown format Неизвестный формат
{kind}, {instances} {kind}, {instances}
{kind}, {rows} × {cols} {kind}, {rows} × {cols}
{grid}, {instances} {grid}, {instances}
Can't render this file because it is too large.
+6
View File
@@ -2406,6 +2406,12 @@ font-technology Variable Variabla
{width} × {height} px {width} × {height} px
{size} — {file} {size} – {file}
{n} ppi {n} ppi
{format}; {size}; {detail} {format}; {size}; {detail}
{x} × {y} ppi {x} × {y} ppi
resolution unavailable upplösning inte tillgänglig
estimated memory {memory} uppskattat minne {memory}
memory unavailable minne inte tillgängligt
Unknown format Okänt format
{kind}, {instances} {kind}, {instances}
{kind}, {rows} × {cols} {kind}, {rows} × {cols}
{grid}, {instances} {grid}, {instances}
Can't render this file because it is too large.
+9 -3
View File
@@ -1061,12 +1061,12 @@ fn document_info_labels_are_in_complete_catalogs() {
}
/// The values Document Info makes and shows in the interface language: the font states and
/// embedding permissions, the templates of the font, image, raster effects and Repeat object
/// values, the names of gradients named by their kind, the counted uses, instances, rows and
/// embedding permissions, the templates of the font, image (format, size, resolution and memory),
/// raster effects and Repeat object values, the names of gradients named by their kind, the counted uses, instances, rows and
/// columns, and the transparency settings' values.
#[test]
fn document_info_values_are_in_complete_catalogs() {
const VALUES: [&str; 22] = [
const VALUES: [&str; 28] = [
"unknown type",
"{type}; {uses}",
"built in",
@@ -1081,6 +1081,12 @@ fn document_info_values_are_in_complete_catalogs() {
"{width} × {height} px",
"{size} — {file}",
"{n} ppi",
"{format}; {size}; {detail}",
"{x} × {y} ppi",
"resolution unavailable",
"estimated memory {memory}",
"memory unavailable",
"Unknown format",
"{kind}, {instances}",
"{kind}, {rows} × {cols}",
"{grid}, {instances}",
+6
View File
@@ -7178,6 +7178,12 @@ theme Appearance Görünüm
{width} × {height} px {width} × {height} px
{size} — {file} {size} — {file}
{n} ppi {n} ppi
{format}; {size}; {detail} {format}; {size}; {detail}
{x} × {y} ppi {x} × {y} ppi
resolution unavailable çözünürlük kullanılamıyor
estimated memory {memory} tahmini bellek {memory}
memory unavailable bellek kullanılamıyor
Unknown format Bilinmeyen biçim
{kind}, {instances} {kind}, {instances}
{kind}, {rows} × {cols} {kind}, {rows} × {cols}
{grid}, {instances} {grid}, {instances}
Can't render this file because it is too large.
+6
View File
@@ -2512,6 +2512,12 @@ file-filter Templates Шаблони
{width} × {height} px {width} × {height} px
{size} — {file} {size} — {file}
{n} ppi {n} ppi
{format}; {size}; {detail} {format}; {size}; {detail}
{x} × {y} ppi {x} × {y} ppi
resolution unavailable роздільна здатність недоступна
estimated memory {memory} орієнтовна пам’ять {memory}
memory unavailable пам’ять недоступна
Unknown format Невідомий формат
{kind}, {instances} {kind}, {instances}
{kind}, {rows} × {cols} {kind}, {rows} × {cols}
{grid}, {instances} {grid}, {instances}
Can't render this file because it is too large.
+6
View File
@@ -3139,6 +3139,12 @@ digits Hindi Hindi
{width} × {height} px {width} × {height} px
{size} — {file} {size} — {file}
{n} ppi {n} ppi
{format}; {size}; {detail} {format}; {size}; {detail}
{x} × {y} ppi {x} × {y} ppi
resolution unavailable không có độ phân giải
estimated memory {memory} bộ nhớ ước tính {memory}
memory unavailable không có thông tin bộ nhớ
Unknown format Định dạng không xác định
{kind}, {instances} {kind}, {instances}
{kind}, {rows} × {cols} {kind}, {rows} × {cols}
{grid}, {instances} {grid}, {instances}
Can't render this file because it is too large.
+6
View File
@@ -2367,6 +2367,12 @@ file-filter Templates 模板
{width} × {height} px {width} × {height} px
{size} — {file} {size} — {file}
{n} ppi {n} ppi
{format}; {size}; {detail} {format};{size};{detail}
{x} × {y} ppi {x} × {y} ppi
resolution unavailable 分辨率不可用
estimated memory {memory} 估计内存 {memory}
memory unavailable 内存不可用
Unknown format 未知格式
{kind}, {instances} {kind},{instances}
{kind}, {rows} × {cols} {kind},{rows} × {cols}
{grid}, {instances} {grid},{instances}
Can't render this file because it is too large.
+6
View File
@@ -3805,6 +3805,12 @@ liquify-list-end {0}, {1} {0}和{1}
{width} × {height} px {width} × {height} px
{size} — {file} {size} — {file}
{n} ppi {n} ppi
{format}; {size}; {detail} {format};{size};{detail}
{x} × {y} ppi {x} × {y} ppi
resolution unavailable 解析度無法使用
estimated memory {memory} 估計記憶體 {memory}
memory unavailable 記憶體無法使用
Unknown format 未知格式
{kind}, {instances} {kind},{instances}
{kind}, {rows} × {cols} {kind},{rows} × {cols}
{grid}, {instances} {grid},{instances}
Can't render this file because it is too large.
+73 -4
View File
@@ -226,11 +226,32 @@ fn font_detail_value(e: &Value) -> Option<String> {
}
}
/// An `imageObjects` entry as Linked Images and Embedded Images show it: its size in pixels, and
/// for a linked image the file it shows.
/// An `imageObjects` entry as Linked Images and Embedded Images show it: its format, its size in
/// pixels, and for a linked image its resolution and the file it shows, for an embedded one the
/// memory its pixels take. Format names and file names stay as they are.
fn image_value(o: &Value) -> Option<String> {
use vectorcraft_engine::cmd::{byte_size, ppi_number};
let format = match &o["format"] {
Value::Null => tl!("Unknown format"),
f => f.as_str()?,
};
let size = fill(tl!("{width} × {height} px"), &[("width", &o["width"].as_u64()?.to_string()), ("height", &o["height"].as_u64()?.to_string())]);
if o["linked"] == true { Some(fill(tl!("{size} — {file}"), &[("size", &size), ("file", o["file"].as_str()?)])) } else { Some(size) }
let detail = if o["linked"] == true {
match &o["effectivePpi"] {
Value::Null => tl!("resolution unavailable").to_string(),
ppi => {
let (x, y) = (ppi_number(ppi.get(0)?.as_f64()?), ppi_number(ppi.get(1)?.as_f64()?));
if x == y { fill(tl!("{n} ppi"), &[("n", &x)]) } else { fill(tl!("{x} × {y} ppi"), &[("x", &x), ("y", &y)]) }
}
}
} else {
match &o["memoryBytes"] {
Value::Null => tl!("memory unavailable").to_string(),
bytes => fill(tl!("estimated memory {memory}"), &[("memory", &byte_size(bytes.as_u64()?))]),
}
};
let shown = fill(tl!("{format}; {size}; {detail}"), &[("format", format), ("size", &size), ("detail", &detail)]);
if o["linked"] == true { Some(fill(tl!("{size} — {file}"), &[("size", &shown), ("file", o["file"].as_str()?)])) } else { Some(shown) }
}
/// A `repeatObjects` entry as Repeat Objects shows it: its kind and the number of instances it
@@ -597,7 +618,7 @@ mod tests {
let gone = fonts.iter().find(|(l, _)| l.starts_with("Qx Absent Family")).unwrap_or_else(|| panic!("{fonts:?}")).1.clone();
assert!(gone == "fehlt" || gone.starts_with("fehlt: angezeigt in "), "{gone}");
assert_eq!(images.len(), 1);
assert!(images[0].1.ends_with(" px") && images[0].1.contains(" × "), "{images:?}");
assert!(images[0].1.contains(" × ") && images[0].1.contains(" px; geschätzter Speicher ") && images[0].1.ends_with(" B"), "{images:?}");
// A swatch named like a kind keeps its name; the gradient named by its kind is translated.
assert_eq!(value(&gradients, "Glow"), "Linear gradient, Radialer Verlauf");
assert_eq!(value(&selected, "Glow"), "Linear gradient, Radialer Verlauf");
@@ -650,6 +671,54 @@ mod tests {
assert!(report.contains("Source Sans 3 Regular: TrueType; 2 uses\n"), "{report}");
}
/// Linked Images and Embedded Images show each image's format, size, resolution or memory in
/// the interface language, the format and file names as they are; values that do not fit an
/// image entry are shown as `document.info` gives the row.
#[test]
fn image_details_show_in_the_interface_language() {
let linked = |format: Value, ppi: Value| json!({"name": "a.png", "width": 3, "height": 2, "linked": true, "file": "/art/a.png", "format": format, "effectivePpi": ppi});
let embedded =
|memory: Value| json!({"name": "Image", "width": 3, "height": 2, "linked": false, "file": null, "format": "PNG", "memoryBytes": memory});
let shown = || {
[
linked(json!("PNG"), json!([150.0, 150.0])),
linked(json!(null), json!([144.0, 72.0])),
linked(json!("TIFF"), json!(null)),
embedded(json!(1536)),
embedded(json!(null)),
]
.map(|o| image_value(&o))
};
assert_eq!(
shown(),
[
"PNG; 3 × 2 px; 150 ppi — /art/a.png",
"Unknown format; 3 × 2 px; 144 × 72 ppi — /art/a.png",
"TIFF; 3 × 2 px; resolution unavailable — /art/a.png",
"PNG; 3 × 2 px; estimated memory 1.5 KiB",
"PNG; 3 × 2 px; memory unavailable",
]
.map(|v| Some(v.to_string()))
);
let Some(de) = crate::i18n::Lang::from_code("de") else { panic!("no German catalog") };
crate::i18n::set_current(de);
let german = shown();
crate::i18n::set_current(crate::i18n::Lang::EN);
assert_eq!(
german,
[
"PNG; 3 × 2 px; 150 ppi – /art/a.png",
"Unbekanntes Format; 3 × 2 px; 144 × 72 ppi – /art/a.png",
"TIFF; 3 × 2 px; Auflösung nicht verfügbar – /art/a.png",
"PNG; 3 × 2 px; geschätzter Speicher 1.5 KiB",
"PNG; 3 × 2 px; Speicher nicht verfügbar",
]
.map(|v| Some(v.to_string()))
);
assert_eq!(image_value(&linked(json!("PNG"), json!([150.0]))), None);
assert_eq!(image_value(&embedded(json!("big"))), None);
}
/// Document shows the transparency settings with their values in the interface language (two
/// custom grid colors as they are), and while the Artboard tool is the current tool the
/// artboards it has selected, following its selection without an edit to the document.
+9 -3
View File
@@ -9948,9 +9948,15 @@ type in a mask or in a symbol's or pattern's art once however many objects show
(`[{font, match, family, style, file, embedding}]`: each font of `fonts`, in order, as the fontDetails category's rows give it: `match` is `exact`, `style` (a style the family lacks, shown in
`family` `style`), `missingWithFallback` (not installed, shown in `family` `style`) or `missing`; `file` is the face's
file name, null for a built-in face; `embedding` is `allowed`, `editing`, `previewPrint` or `forbidden`, null when no
face is found), `imageObjects` (`[{name, width, height, linked, file}]`: the image objects in the order the
linkedImages and embeddedImages categories list them, with the file a linked image's row shows and null for an
embedded one), `document.unitId` (the document's units as Preferences › Units names them, such as `millimeters`, beside
face is found), `imageObjects` (`[{name, width, height, linked, file, format, effectivePpi, memoryBytes,
storedBytes}]`: the image objects in the order the linkedImages and embeddedImages categories list them, with the file
a linked image's row shows and null for an embedded one; `format` is a linked image's file format by its extension,
else the format of the pixels the document holds, null when neither is known; `effectivePpi` is `[x, y]`, the pixels
per inch at the size the image is placed at (a distorted image measured at its middle), null when it has no area;
`memoryBytes` is, for an embedded image, width × height × 4, the bytes of the 8-bit RGBA pixels it is drawn from, and
`storedBytes` is the bytes of the encoded image the document holds; both are null for a linked image; a linkedImages row reads
`PNG; 1200 × 800 px; 150 ppi — /art/photo.png` and an embeddedImages row `PNG; 1200 × 800 px; estimated memory 3.7 MiB`,
with `Unknown format`, `resolution unavailable` or `memory unavailable` for a value that is null), `document.unitId` (the document's units as Preferences › Units names them, such as `millimeters`, beside
the English `document.units`), `document.transparency` (`{gridSize, gridColors, gridColorsName, simulatePaper,
flattenerPreset}`: File › Document Setup's transparency settings, the grid's size (`small`, `medium` or `large`), its
two colors as `#rrggbb`, their preset's name or `Custom`, Simulate Colored Paper and the flattener preset, which the
+1
View File
@@ -2071,6 +2071,7 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur
The Brushes panel's Delete Brush button and panel menu item ask "Delete the selected brushes?" with Yes and No when none of the brushes is in use. Alt-click (Option-click on macOS) on the button deletes them without asking, as the [Default keyboard shortcuts](https://web.archive.org/web/20260726060015/https://helpx.adobe.com/illustrator/using/default-keyboard-shortcuts.html) page lists for panel deletion outside the Layers panel (archived copy). When a stroke uses one of the brushes, the button, Alt-click and the menu item all ask with Remove Strokes and Cancel; Remove Strokes deletes the brushes and the strokes that used them become plain strokes. Tests: `panels::brushes::tests`, `dialogs::brush_delete::tests`.
Document Info has a Brushes category after Graphic Styles. It lists the names and types of the brushes applied to the artwork, as the [Document Info panel](https://helpx.adobe.com/illustrator/desktop/get-started/learn-the-basics/document-info-panel.html) page describes, or with Selection Only the brushes that the selected objects' strokes use. The Document Info report and Package's report list them too (`document.info {category: "brushes"}`, `brushNames`, `brushes`). Listing each brush once, leaving out the Brushes panel's brushes no art uses (`panelBrushNames` lists the panel's brushes), hidden strokes, strokes at an opacity of 0, strokes with no paint or width, guides, paths with no segment, type that draws no characters, a group's or layer's own strokes, a compound path member's own strokes and an image's strokes without a shape, and listing a brush the panel does not hold as missing, are VectorCraft's own rules. Tests: `cmd::docinfo::tests::info_lists_the_brushes` and `info_brushes_skip_undrawn_strokes_and_name_missing_brushes` (vectorcraft-engine).
Document Info's Fonts category gives each font's type and number of uses beside its name, as the [help page](https://helpx.adobe.com/illustrator/desktop/get-started/learn-the-basics/document-info-panel.html) describes, for the whole document or with Selection Only for the selected type. The Document Info report and Package's report give them too (`document.info {category: "fonts"}`, `fontUses`), and the panel shows the type and count in the interface language. Counting a use as a text object set in the font (once however many of its runs use it, and the type in a mask or in a symbol's or pattern's art once however many objects show it), naming the type by the face's outlines (TrueType for `glyf`, OpenType for `CFF` or `CFF2`) and showing an unknown type for a font that is not installed in the family and style the type names are VectorCraft's own rules. Tests: `cmd::docinfo::tests::info_fonts_give_each_font_s_type_and_uses` (vectorcraft-engine), `panels::doc_info::tests::font_types_and_uses_show_in_the_interface_language` (vectorcraft-ui-egui), `fontdb::face::tests::outline_format_follows_the_outline_tables` (vectorcraft-text).
Document Info's Linked Images category gives each linked image's format, size in pixels, resolution and file, and its Embedded Images category gives each embedded image's format, size in pixels and memory size, as the [help page](https://helpx.adobe.com/illustrator/desktop/get-started/learn-the-basics/document-info-panel.html) describes, for the whole document or with Selection Only for the selected images. The Document Info report and Package's report give them too (`document.info {category: "linkedImages"}`, `imageObjects`' `format`, `effectivePpi`, `memoryBytes` and `storedBytes`), and the panel shows them in the interface language. Taking the format from a linked file's extension or else from the pixels the document holds, measuring the resolution at the size the image is placed at, counting the memory as the 8-bit RGBA pixels the image is drawn from (width × height × 4), and showing `Unknown format` or `resolution unavailable` when those are not known are VectorCraft's own rules. Tests: `cmd::docinfo::tests::image_rows_give_format_resolution_and_memory` and `byte_sizes_and_resolutions_read_to_a_tenth` (vectorcraft-engine), `panels::doc_info::tests::image_details_show_in_the_interface_language` (vectorcraft-ui-egui).
Document Info has a Repeat Objects category after Embedded Images. It lists each radial, grid and mirror Repeat object by name with its kind and the number of instances it makes. For a grid it gives the rows and columns instead, followed by the number of instances it draws when that is fewer. With Selection Only it lists the Repeat objects in the selection. The Document Info report and Package's report list them too (`document.info {category: "repeats"}`, `repeatObjects`).
Document Info's Pattern Objects category lists the objects whose fill or stroke is a pattern, the category the [Document Info panel](https://helpx.adobe.com/illustrator/desktop/get-started/learn-the-basics/document-info-panel.html) page describes, each by name with the patterns it uses. With Selection Only it lists those in the selection, and the Document Info report and Package's report list them too (`document.info {category: "patterns"}`, `patternObjects`). Listing an object with a pattern fill and a pattern stroke once, listing objects inside groups and type objects whose characters use a pattern, and leaving out hidden fills and strokes, fills and strokes at an opacity of 0, strokes with no width, guides, a compound path member's own fills and strokes, an image's fills and strokes without a shape, characters the type does not draw and patterns no art uses, and counting the listed objects in Objects, are VectorCraft's own rules. Test: `cmd::docinfo::tests::info_lists_the_pattern_objects` (vectorcraft-engine).
Document Info's Gradient Objects category lists the objects whose fill or stroke is a gradient, the category the [Document Info panel](https://helpx.adobe.com/illustrator/desktop/get-started/learn-the-basics/document-info-panel.html) page describes as the count of objects with gradient fills or strokes. Each object is listed by name with the gradients it uses. With Selection Only it lists those in the selection, and the Document Info report and Package's report list them too (`document.info {category: "gradients"}`, `gradientObjects`). Naming a linked gradient by its swatch and any other gradient by its kind, and leaving out paint that draws nothing by the rules Pattern Objects follows, gradient swatches no art uses, gradient meshes and gradients drawn by effects, are VectorCraft's own rules. Objects counts the listed objects as Gradient Objects. Test: `cmd::docinfo::tests::info_lists_the_gradient_objects` (vectorcraft-engine).