WebP: Lossy with a Quality setting writes a lossy WebP file

WebP Options has a Compression menu (Lossless, Lossy) and a Quality
slider from 0 to 100 that is enabled for Lossy. document.export,
document.serialize and Export for Screens take lossless: false with
quality (default 90) and write a VP8 file, with an ALPH chunk that keeps
the alpha exactly when some pixels are not opaque. Lossless stays the
default. A WebP quality above 100, or one that is not a whole number,
is refused with an error.

The encoder is the one craft-image-codecs already provides; no
dependency changes. The note that lossy WebP isn't available, its
catalog rows and the format text that described it are removed.
This commit is contained in:
dotCooCoo committed 2026-11-16 12:30:56 -08:00
1 parent 5fd8cf2c45
commit 2f7e60dd54
44 files changed
+348 -114

No files matched your search

+2 -2
View File
@@ -36,7 +36,7 @@ pub fn specs() -> Vec<CommandSpec> {
"Export Document",
[],
None,
"{path?, format?: svg|svgz|pdf|ai|png|jpg|webp|gif|png8|txt|dxf|eps|emf|wmf|hpgl|tiff|bmp|tga|psd|vectorcraft|template (default: from the path's extension, else png; png8 writes an indexed .png; ait, a .ait template, is written by file.saveAsTemplate; an exporter plug-in's format is plugin.<plug-in id>, which an extension only it lists picks too), params?: {…} (an exporter plug-in's parameters; missing ones take their defaults, see plugin.info), selectedOnly?: false (the selected objects alone, in the layers and groups that hold them; an object of a blend, envelope, repeat or intertwine on its own), includeArtboardFill?: true (raster, PDF, SVG and EPS draw each exported artboard's background color behind its art, a transparent background too; false leaves it out), artboard?: 0, artboards?: [i…], rect?: [x, y, width, height] (raster formats: that area of the page in points, y down, instead of an artboard; not with artboard, artboards, range or useArtboards), range?: \"1-3, 5\" | \"all\" (1-based; PDF and .ai write one page per artboard, default all; SVG writes one file per artboard, {stem}-{artboard}.svg; raster formats write one artboard), useArtboards?: true (raster: one file per chosen artboard, default all, {stem}-{artboard}.{ext}; pdf/ai: every page) | false (pdf/ai/raster: the bounds of the visible art; pdf/ai: of the layers the file draws, without editing data, with a warning, and ai refuses pdfCompatible: false; SVG has it as an SVG option), ppi?: number (raster formats: pixels per inch, stored in the file; wins over scale; without either, the document's raster effects resolution), scale?: number (pixels per point), background?: transparent|white|black|\"#rrggbb\" (jpg: white when transparent; #rrggbbaa and #rgba are refused here and in matte), antiAlias?: none|art (default)|type (text snapped to pixels), interlaced?: false (png, Adam7), embedIcc?: true (png: an sRGB chunk marks the colours as sRGB), quality?: 90 (jpg: 0–100), colorModel?: rgb|cmyk|gray (jpg), method?: baseline|optimized|progressive, scans?: 3 (3–5, progressive), embedIcc?: true, imageMap?: none|client|server (an HTML or NCSA map of the objects with a URL, written as <stem>.html / <stem>.map), colors?: 256 (gif/png8: 2–256), reduction?: perceptual|selective (default)|adaptive|web|blackWhite|gray, dither?: none|diffusion (default)|pattern|noise, ditherAmount?: 100, transparency?: true, matte?: white|\"#rrggbb\"|none, interlaced?, lossless?: true (webp: lossy WebP isn't available yet: written lossless, with a warning), encoding?: utf8|utf16 (txt: the stories in stacking order, back to front, a thread once; utf16 with a byte order mark), lineEndings?: lf|crlf, selectionOnly?: false, svg?: {styling, outlineText, images, objectIds, decimals, minify, responsive, useArtboards, preserveEditing, metadata, fewerTspans, hiddenLayers, encoding, profile, embedFonts, variableData} (see document.formats), …the SVG options given flat instead, …the PDF options of document.exportPdf, …the DXF options of document.exportDxf (useArtboards: one drawing per artboard), …the EPS options of document.exportEps (useArtboards: one file per artboard, {stem}_{artboard}.eps, after a central {stem}.eps of the whole document when there are two or more and art shows; else the visible art), …emf and wmf write one picture of the artboard (useArtboards: true one file per chosen artboard, false the bounds of the visible art; EMF keeps curves, clipping, transparent images and gradients as images clipped to their shape; WMF flattens curves into polygons behind a placeable header; what a format leaves out comes back in warnings), …hpgl writes a plot of the artboard as pen moves for plotters and cutters (each visible path once along its line in plotter units; useArtboards: true one file per chosen artboard, false the bounds of the art it plots, without placed images, unpainted paths and art at 0% opacity), hpglVersion?: hpgl (default: IN, SP, PU, PD) | hpgl2 (also NP and PC pen colors, each pen's paths as one encoded polyline PE), curveTolerance?: 0.1 (points, 0.01 to 10), pens?: [\"#rrggbb\"…] (pen 1 first, up to 255; each path takes the nearest; default a pen per color in the order the art first draws in it, numbered alike in every file), origin?: bottomLeft (default) | center, sortPaths?: false (each pen's next path the nearest), insideFirst?: false (a path after the pen's paths that lie inside it), colorModel?: rgb|cmyk|gray (tiff: rgb keeps transparency as an alpha channel), lzw?: true, byteOrder?: little|big, embedIcc?: true, colorModel?: rgb|gray (bmp), depth?: 24 (bmp: 1 black and white, 4|8 a palette by reduction and dither, 16, 24, 32 with alpha), fileFormat?: windows|os2 (1, 4, 8 or 24 bits), rle?: false (4 and 8 bits, windows), flipRows?: false (top-down rows), depth?: 24 (tga: 16 one-bit alpha, 24, 32 with alpha), colorModel?: rgb|cmyk|gray (psd), layers?: true (each top-level layer a pixel layer with its opacity and blend mod Line truncated
"{path?, format?: svg|svgz|pdf|ai|png|jpg|webp|gif|png8|txt|dxf|eps|emf|wmf|hpgl|tiff|bmp|tga|psd|vectorcraft|template (default: from the path's extension, else png; png8 writes an indexed .png; ait, a .ait template, is written by file.saveAsTemplate; an exporter plug-in's format is plugin.<plug-in id>, which an extension only it lists picks too), params?: {…} (an exporter plug-in's parameters; missing ones take their defaults, see plugin.info), selectedOnly?: false (the selected objects alone, in the layers and groups that hold them; an object of a blend, envelope, repeat or intertwine on its own), includeArtboardFill?: true (raster, PDF, SVG and EPS draw each exported artboard's background color behind its art, a transparent background too; false leaves it out), artboard?: 0, artboards?: [i…], rect?: [x, y, width, height] (raster formats: that area of the page in points, y down, instead of an artboard; not with artboard, artboards, range or useArtboards), range?: \"1-3, 5\" | \"all\" (1-based; PDF and .ai write one page per artboard, default all; SVG writes one file per artboard, {stem}-{artboard}.svg; raster formats write one artboard), useArtboards?: true (raster: one file per chosen artboard, default all, {stem}-{artboard}.{ext}; pdf/ai: every page) | false (pdf/ai/raster: the bounds of the visible art; pdf/ai: of the layers the file draws, without editing data, with a warning, and ai refuses pdfCompatible: false; SVG has it as an SVG option), ppi?: number (raster formats: pixels per inch, stored in the file; wins over scale; without either, the document's raster effects resolution), scale?: number (pixels per point), background?: transparent|white|black|\"#rrggbb\" (jpg: white when transparent; #rrggbbaa and #rgba are refused here and in matte), antiAlias?: none|art (default)|type (text snapped to pixels), interlaced?: false (png, Adam7), embedIcc?: true (png: an sRGB chunk marks the colours as sRGB), quality?: 90 (jpg: 0–100), colorModel?: rgb|cmyk|gray (jpg), method?: baseline|optimized|progressive, scans?: 3 (3–5, progressive), embedIcc?: true, imageMap?: none|client|server (an HTML or NCSA map of the objects with a URL, written as <stem>.html / <stem>.map), colors?: 256 (gif/png8: 2–256), reduction?: perceptual|selective (default)|adaptive|web|blackWhite|gray, dither?: none|diffusion (default)|pattern|noise, ditherAmount?: 100, transparency?: true, matte?: white|\"#rrggbb\"|none, interlaced?, lossless?: true (webp: every pixel kept exactly; false writes lossy WebP, a smaller file that loses some detail), quality?: 90 (webp with lossless: false: 0–100, higher keeps more detail in a larger file; more than 100 is refused), encoding?: utf8|utf16 (txt: the stories in stacking order, back to front, a thread once; utf16 with a byte order mark), lineEndings?: lf|crlf, selectionOnly?: false, svg?: {styling, outlineText, images, objectIds, decimals, minify, responsive, useArtboards, preserveEditing, metadata, fewerTspans, hiddenLayers, encoding, profile, embedFonts, variableData} (see document.formats), …the SVG options given flat instead, …the PDF options of document.exportPdf, …the DXF options of document.exportDxf (useArtboards: one drawing per artboard), …the EPS options of document.exportEps (useArtboards: one file per artboard, {stem}_{artboard}.eps, after a central {stem}.eps of the whole document when there are two or more and art shows; else the visible art), …emf and wmf write one picture of the artboard (useArtboards: true one file per chosen artboard, false the bounds of the visible art; EMF keeps curves, clipping, transparent images and gradients as images clipped to their shape; WMF flattens curves into polygons behind a placeable header; what a format leaves out comes back in warnings), …hpgl writes a plot of the artboard as pen moves for plotters and cutters (each visible path once along its line in plotter units; useArtboards: true one file per chosen artboard, false the bounds of the art it plots, without placed images, unpainted paths and art at 0% opacity), hpglVersion?: hpgl (default: IN, SP, PU, PD) | hpgl2 (also NP and PC pen colors, each pen's paths as one encoded polyline PE), curveTolerance?: 0.1 (points, 0.01 to 10), pens?: [\"#rrggbb\"…] (pen 1 first, up to 255; each path takes the nearest; default a pen per color in the order the art first draws in it, numbered alike in every file), origin?: bottomLeft (default) | center, sortPaths?: false (each pen's next path the nearest), insideFirst?: false (a path after the pen's paths that lie inside it), colorModel?: rgb|cmyk|gray (tiff: rgb keeps transparency as an alpha channel), lzw?: true, byteOrder?: little|big, embedIcc?: true, colorModel?: rgb|gray (bmp), depth?: 24 (bmp: 1 black and white, 4|8 a palette by reduction and dither, 16, 24, 32 with alpha), fileFormat?: windows|os2 (1, 4, 8 or 24 bits), rle?: false (4 and 8 bits, windows), flipRows?: false (top-down rows), depth?: 24 (tga: 16 one-b Line truncated
has_doc,
export::export
),
@@ -54,7 +54,7 @@ pub fn specs() -> Vec<CommandSpec> {
"Export for Screens",
["File", "Export"],
None,
"{folder?, zip?: false (one .zip of every file, each deflated or stored, whichever is smaller: no folder → {name, dataBase64, bytes, files: [name…]}; with a folder it is written there → {path, bytes, files}), artboard?: index | artboards?: [index…] | range?: \"1-3\" (default all), assets?: [asset id…] (instead of artboards: each asset's art alone, cropped to its bounds and named after the asset; see assets.list), layers?: [layer id…] (instead of artboards: each layer's art alone, sublayers included, named after the layer), selection?: one|each (instead of artboards: the selected art as one file, or a file per selected object, named after it), fullDocument?: false (one file per format instead: a PDF of every artboard, other formats the bounds of all visible art, named after the document), includeBleed?: false (artboards grown by the document's bleed), includeArtboardFill?: true (Include Artboard Fill: each artboard's background color behind its art; false leaves it out), pdfs?: multiple|single (Export PDFs As: with several artboards, single writes them as the pages of one PDF per PDF row, named after the document; refused with assets, layers or selection: each), exportPreset?: (a preset of document.exportPresets.list: its settings, under these params), subfolders?: false (each row's files in a sub-folder: its folder, else its size for raster (1x, 2x, 100w…) or its format (SVG, PDF)), folders?: none|rows (as subfolders)|format (a folder per extension: png, svg, pdf…)|item (a folder per artboard, asset, layer or object)|itemFormat (item/extension) (default: rows with subfolders or a preset, else none), name?: (a file name pattern instead of the item's name, with <filename> for the document, <name> for the artboard, asset, layer or object, <index> from 1, #### for the counter zero-padded to the run of #, <format>, <scale>, <suffix> (else the row's suffix ends the name), YYYYMMDD, YYYY-MM-DD, YYYY, <date>, <time>, <YYYY>, <MM>, <DD>, <hh>, <mm> and <ss>; a trailing .ext is dropped, as in `COMPANY-Logo-<filename>-####-YYYYMMDD`; different files it names alike get -2, -3…), counterStart?: 1, counterPer?: item (every file of an item has its number)|file, date?: YYYY-MM-DD (the date the pattern uses; default today, UTC), preset?: mobile (PNG 1x, 2x, 3x) | density (PNG 0.75x–4x in ldpi…xxxhdpi sub-folders) instead of formats (turns subfolders on), formats?: [{format: png|png8|jpg|webp|gif|tiff|bmp|tga|psd|svg|svgz|pdf|eps|ai|vectorcraft, scale?: 1 | \"2x\" | \"100w\" | \"100h\" | \"72ppi\", width?: px | height?: px | ppi? (raster only; width, then height, then ppi win over scale), suffix?: (raster default: @2x, @100w, @100h, none at 1x; vector formats drop size suffixes), folder?: (its sub-folder), quality?: (jpg 0–100), …the format's options (antiAlias, background, preset (pdf)…)}], settings?: {png|png8|jpg|webp|gif|tiff|bmp|tga|psd|svg|svgz|pdf|eps|ai|vectorcraft: {…options for every row of that format}} (rows' own options win), prefix?, antiAlias?: none|art|type (raster rows without their own), openLocation?: (remembered; the app shows the files after exporting)} one file per artboard and format (a PDF holds its artboard alone; artboards with the same name, in any case, get -2, -3…; an unnamed one is Artboard-N; a row whose file would take a name another row's file has, in any case, gets -2, -3… too, and identical rows write one file; row folders that differ only in case are one folder, spelled as the first row spells it) → {files: [path…]} (into the folder of exportPreset, outside the automation read roots: no ZIP path, and files relative to that folder); no folder → {files: [{name, dataBase64}]} (names include sub-folders: 2x/Icon@2x.png); every reply has warnings: [the encoders' warnings for the files, each once: an image that couldn't be decoded, type written in the fallback font…]. eps, ai and vectorcraft rows write a document of the item alone (its one artboard). The params (but zip and assets) are remembered in the document (document.exportSettings; not an undo step). A key it doesn't take, a key no format takes in a format row or in settings, settings for a format it doesn't write, and an unknown key inside a PDF, EPS or SVG option's object, are refused; a key only another format takes in a row or in settings is not used, and warnings name it as given (formats[0].quality; a key in settings only when no row of that format reads it; not a key of an exportPreset). Under automation read roots, an svg or svgz row, and a row whose files carry the native document (vectorcraft, eps, ai but a version 7 file, a pdf with preserveEditing on that holds every artboard of the document it is written from), is refused, before the folder is made or any file is written, while the document links a JavaScript file outside them, or while the row's file would name a linked image's file outside them, as document.export refuses it",
"{folder?, zip?: false (one .zip of every file, each deflated or stored, whichever is smaller: no folder → {name, dataBase64, bytes, files: [name…]}; with a folder it is written there → {path, bytes, files}), artboard?: index | artboards?: [index…] | range?: \"1-3\" (default all), assets?: [asset id…] (instead of artboards: each asset's art alone, cropped to its bounds and named after the asset; see assets.list), layers?: [layer id…] (instead of artboards: each layer's art alone, sublayers included, named after the layer), selection?: one|each (instead of artboards: the selected art as one file, or a file per selected object, named after it), fullDocument?: false (one file per format instead: a PDF of every artboard, other formats the bounds of all visible art, named after the document), includeBleed?: false (artboards grown by the document's bleed), includeArtboardFill?: true (Include Artboard Fill: each artboard's background color behind its art; false leaves it out), pdfs?: multiple|single (Export PDFs As: with several artboards, single writes them as the pages of one PDF per PDF row, named after the document; refused with assets, layers or selection: each), exportPreset?: (a preset of document.exportPresets.list: its settings, under these params), subfolders?: false (each row's files in a sub-folder: its folder, else its size for raster (1x, 2x, 100w…) or its format (SVG, PDF)), folders?: none|rows (as subfolders)|format (a folder per extension: png, svg, pdf…)|item (a folder per artboard, asset, layer or object)|itemFormat (item/extension) (default: rows with subfolders or a preset, else none), name?: (a file name pattern instead of the item's name, with <filename> for the document, <name> for the artboard, asset, layer or object, <index> from 1, #### for the counter zero-padded to the run of #, <format>, <scale>, <suffix> (else the row's suffix ends the name), YYYYMMDD, YYYY-MM-DD, YYYY, <date>, <time>, <YYYY>, <MM>, <DD>, <hh>, <mm> and <ss>; a trailing .ext is dropped, as in `COMPANY-Logo-<filename>-####-YYYYMMDD`; different files it names alike get -2, -3…), counterStart?: 1, counterPer?: item (every file of an item has its number)|file, date?: YYYY-MM-DD (the date the pattern uses; default today, UTC), preset?: mobile (PNG 1x, 2x, 3x) | density (PNG 0.75x–4x in ldpi…xxxhdpi sub-folders) instead of formats (turns subfolders on), formats?: [{format: png|png8|jpg|webp|gif|tiff|bmp|tga|psd|svg|svgz|pdf|eps|ai|vectorcraft, scale?: 1 | \"2x\" | \"100w\" | \"100h\" | \"72ppi\", width?: px | height?: px | ppi? (raster only; width, then height, then ppi win over scale), suffix?: (raster default: @2x, @100w, @100h, none at 1x; vector formats drop size suffixes), folder?: (its sub-folder), quality?: (jpg 0–100; webp 0–100 with lossless: false), …the format's options (antiAlias, background, preset (pdf)…)}], settings?: {png|png8|jpg|webp|gif|tiff|bmp|tga|psd|svg|svgz|pdf|eps|ai|vectorcraft: {…options for every row of that format}} (rows' own options win), prefix?, antiAlias?: none|art|type (raster rows without their own), openLocation?: (remembered; the app shows the files after exporting)} one file per artboard and format (a PDF holds its artboard alone; artboards with the same name, in any case, get -2, -3…; an unnamed one is Artboard-N; a row whose file would take a name another row's file has, in any case, gets -2, -3… too, and identical rows write one file; row folders that differ only in case are one folder, spelled as the first row spells it) → {files: [path…]} (into the folder of exportPreset, outside the automation read roots: no ZIP path, and files relative to that folder); no folder → {files: [{name, dataBase64}]} (names include sub-folders: 2x/Icon@2x.png); every reply has warnings: [the encoders' warnings for the files, each once: an image that couldn't be decoded, type written in the fallback font…]. eps, ai and vectorcraft rows write a document of the item alone (its one artboard). The params (but zip and assets) are remembered in the document (document.exportSettings; not an undo step). A key it doesn't take, a key no format takes in a format row or in settings, settings for a format it doesn't write, and an unknown key inside a PDF, EPS or SVG option's object, are refused; a key only another format takes in a row or in settings is not used, and warnings name it as given (formats[0].quality; a key in settings only when no row of that format reads it; not a key of an exportPreset). Under automation read roots, an svg or svgz row, and a row whose files carry the native document (vectorcraft, eps, ai but a version 7 file, a pdf with preserveEditing on that holds every artboard of the document it is written from), is refused, before the folder is made or any file is written, while the document links a JavaScript file outside them, or while the row's file would name a linked image's file outside them, as document.export refuses it",
has_doc,
screens::export_for_screens
),
+22 -5
View File
@@ -241,7 +241,8 @@ struct RasterOptions {
width: Option<f64>,
/// The height of each file in pixels (wins over `ppi` and `scale`).
height: Option<f64>,
quality: Option<u8>,
/// JPEG and lossy WebP quality, read by [`RasterOptions::quality`].
quality: Option<Value>,
background: Option<Value>,
anti_alias: Option<String>,
interlaced: Option<bool>,
@@ -281,6 +282,19 @@ fn clamped_ppi(ppi: f64) -> f64 {
}
impl RasterOptions {
/// `quality` as given: `None` when absent or null, else a whole number 0–255 (JPEG caps it at
/// 100; WebP refuses more than 100), or an error naming it.
fn quality(&self) -> Result<Option<u8>> {
match &self.quality {
None | Some(Value::Null) => Ok(None),
Some(v) => v
.as_u64()
.and_then(|q| u8::try_from(q).ok())
.map(Some)
.ok_or_else(|| bad(C, format!("quality must be a whole number from 0 to 100, not {v}"))),
}
}
/// The pixel size each file is scaled to: `width`, else `height`; `None` when neither is set.
fn pixel_size(&self) -> Result<Option<ScreenSize>> {
let checked = |key: &str, n: f64| {
@@ -311,7 +325,8 @@ impl RasterOptions {
},
anti_alias: self.anti_alias.as_deref().map(anti_alias).transpose().map_err(|e| bad(C, e))?.unwrap_or_default(),
interlaced: self.interlaced.unwrap_or(false),
quality: self.quality.unwrap_or(90).min(100),
quality: self.quality()?.unwrap_or(90).min(100),
webp_lossless: self.lossless.unwrap_or(true),
jpeg: JpegOptions {
color_model,
method: parse(self.method.as_deref(), jpeg::Method::from_id, "method", "baseline, optimized or progressive")?,
@@ -1136,6 +1151,11 @@ fn encode_files(doc: &Document, f: &Format, p: &Value) -> Result<Encoded> {
"psd" => RasterFormat::Psd,
_ => RasterFormat::WebP,
};
if format == RasterFormat::WebP
&& let Some(q) = o.quality()?.filter(|q| *q > 100)
{
return Err(bad(C, format!("quality {q}: WebP quality is 0–100")));
}
check_options(format, &settings)?;
// Use Artboards: one file per chosen artboard (default all); else the one chosen.
let chosen = match use_artboards {
@@ -1182,9 +1202,6 @@ fn encode_files(doc: &Document, f: &Format, p: &Value) -> Result<Encoded> {
}
let regions: Vec<Rect> = enc.files.iter().filter_map(|(b, _)| b.and_then(|b| doc.artboards.get(b))).map(|a| a.rect).collect();
enc.warnings.extend(crate::cmd::fonts::export_overflow_warning(doc, &doc.layers, Some(&regions)));
if format == RasterFormat::WebP && o.lossless == Some(false) {
enc.setting_notes.push("lossy WebP isn't available yet: the file is lossless (exact, but larger)".into());
}
return Ok(enc);
}
_ => return Err(bad(C, format!("no encoder for {} yet", f.label))),
+7 -3
View File
@@ -206,11 +206,15 @@ const LOSSLESS: FormatOption = FormatOption {
name: "lossless",
ty: "boolean",
default: "true",
description: "lossless WebP; false asks for lossy, which isn't available yet (written lossless, with a warning)",
description: "lossless WebP (every pixel kept exactly); false writes lossy WebP at quality: a smaller file that loses some detail",
};
const WEBP_QUALITY: FormatOption =
FormatOption { name: "quality", ty: "integer", default: "90", description: "lossy quality 0–100 (for when lossy WebP is available)" };
const WEBP_QUALITY: FormatOption = FormatOption {
name: "quality",
ty: "integer",
default: "90",
description: "lossy WebP quality 0–100 (with lossless false; higher keeps more detail in a larger file; more than 100 is refused)",
};
/// The options of the palette formats (PNG-8, GIF).
const PALETTE_OPTIONS: &[FormatOption] = &[
@@ -135,26 +135,25 @@ fn formats_list_use_artboards() {
assert!(opts("vectorcraft").get("useArtboards").is_none());
}
/// An export's reply gives what the file loses before its notes on the options, whatever order
/// the encoder gave them: the WebP encoder notes that lossy WebP isn't applied before the export
/// notes the type it drew in the fallback font. With only notes on the options, they keep their
/// order.
/// An export's reply gives what the file loses before its notes on the options: the type the
/// export drew in the fallback font comes before the note on an option WebP doesn't read. With
/// only notes on the options, they keep their order.
#[test]
fn what_the_file_loses_comes_before_a_note_on_the_options() {
let lossy = "lossy WebP isn't available yet: the file is lossless (exact, but larger)";
let unused = "`interlaced` was not used: WebP files don't read it";
let warnings = |s: &mut Session, p: Value| -> Vec<String> {
let r = s.execute("document.export", &p).unwrap();
r["warnings"].as_array().unwrap().iter().filter_map(Value::as_str).map(str::to_string).collect()
};
let mut s = session(60.0, 40.0, 1);
assert_eq!(warnings(&mut s, json!({"format": "webp", "lossless": false})), [lossy]);
assert_eq!(warnings(&mut s, json!({"format": "webp", "interlaced": true})), [unused]);
s.execute("text.create", &json!({"x": 5, "y": 20, "text": "Ab", "font": "Nonexistent Sans Probe"})).unwrap();
let w = warnings(&mut s, json!({"format": "webp", "lossless": false}));
let w = warnings(&mut s, json!({"format": "webp", "interlaced": true}));
assert_eq!(w.len(), 2, "{w:?}");
assert!(w[0].contains("fallback font") && w[0].contains("Nonexistent Sans Probe"), "{w:?}");
assert_eq!(w[1], lossy);
assert_eq!(w[1], unused);
// document.serialize gives them in the same order.
let r = s.execute("document.serialize", &json!({"format": "webp", "lossless": false})).unwrap();
let r = s.execute("document.serialize", &json!({"format": "webp", "interlaced": true})).unwrap();
assert_eq!(r["warnings"], json!(w));
}
@@ -546,20 +546,19 @@ fn type_in_a_missing_family_is_named_once_for_every_format() {
assert!(fallback[0].contains("Nonexistent Sans Probe"), "{fallback:?}");
}
/// What a later file loses comes before a note on the options that an earlier file gave: the
/// first artboard's WebP gives only the lossy WebP note, the second's also says its type doesn't
/// fit.
/// What a later file loses comes before a note on the options: the second artboard's WebP says
/// its type doesn't fit, before the note on the row's option that WebP doesn't read.
#[test]
fn what_any_file_loses_comes_before_the_notes_on_the_options() {
let mut s = session(2);
let second = s.doc().unwrap().doc.artboards[1].rect;
let area = json!({"width": 30, "height": 8});
s.execute("text.create", &json!({"x": second.x0 + 2.0, "y": second.y0 + 2.0, "size": 12, "area": area, "text": "Ab\nCd\nEf\nGh"})).unwrap();
let r = export(&mut s, json!({"formats": [{"format": "webp", "lossless": false}]}));
let r = export(&mut s, json!({"formats": [{"format": "webp", "interlaced": true}]}));
let warnings: Vec<&str> = r["warnings"].as_array().unwrap().iter().filter_map(Value::as_str).collect();
assert_eq!(warnings.len(), 2, "{warnings:?}");
assert!(warnings[0].contains("doesn't fit its frame"), "{warnings:?}");
assert!(warnings[1].starts_with("lossy WebP"), "{warnings:?}");
assert!(warnings[1].starts_with("`formats[0].interlaced` was not used"), "{warnings:?}");
}
#[test]
+106 -32
View File
@@ -53,41 +53,115 @@ fn text_export_writes_the_stories_in_stacking_order() {
let _ = std::fs::remove_dir_all(dir);
}
/// The chunk types of RIFF WebP file `file`, in order.
fn webp_chunks(file: &[u8]) -> Vec<[u8; 4]> {
assert_eq!((&file[..4], &file[8..12]), (&b"RIFF"[..], &b"WEBP"[..]));
let mut chunks = Vec::new();
let mut at = 12;
while at + 8 <= file.len() {
let len = u32::from_le_bytes([file[at + 4], file[at + 5], file[at + 6], file[at + 7]]) as usize;
chunks.push([file[at], file[at + 1], file[at + 2], file[at + 3]]);
at += 8 + len + len % 2;
}
chunks
}
/// The size and straight RGBA pixels of image file `file`.
fn rgba(file: &[u8]) -> (u32, u32, Vec<u8>) {
let img = craft_image_codecs::decode(file).unwrap();
let (w, h) = img.dimensions();
(w, h, img.to_rgba8())
}
/// A 120 × 80 pt document filled with a grid of rectangles in 96 colors.
fn varied_art() -> Session {
let mut s = Session::new();
s.execute("file.new", &json!({"width": 120, "height": 80})).unwrap();
for row in 0..8 {
for col in 0..12 {
s.execute("shape.rectangle", &json!({"x": col * 10, "y": row * 10, "width": 10, "height": 10})).unwrap();
let color = format!("#{:02x}{:02x}{:02x}", col * 21, row * 32, (col * 7 + row * 23) % 256);
s.execute("paint.setFill", &json!({"color": color})).unwrap();
}
}
s
}
#[test]
fn webp_is_lossless_and_says_so_when_lossy_is_asked_for() {
fn webp_is_lossless_by_default_and_lossy_when_asked() {
let mut s = varied_art();
let export = |s: &mut Session, p: Value| -> (Vec<u8>, Value) {
let r = s.execute("document.export", &merge(json!({"format": "webp", "background": "white"}), p)).unwrap();
(b64(&r), r["warnings"].clone())
};
let (lossless, warnings) = export(&mut s, json!({}));
assert_eq!(webp_chunks(&lossless), [*b"VP8L"], "lossless by default");
assert_eq!(warnings, json!([]));
// Quality doesn't change a lossless file.
assert_eq!(export(&mut s, json!({"lossless": true, "quality": 10})).0, lossless);
let (lossy, warnings) = export(&mut s, json!({"lossless": false}));
assert_eq!(webp_chunks(&lossy), [*b"VP8 "], "opaque art is a plain lossy file");
assert_eq!(warnings, json!([]), "no note: the file is lossy");
assert_eq!(export(&mut s, json!({"lossless": false, "quality": 90})).0, lossy, "quality 90 by default");
// At quality 90 each channel stays within 4 levels of the exact pixels on average.
let ((w, h, exact), (lw, lh, near)) = (rgba(&lossless), rgba(&lossy));
assert_eq!((lw, lh), (w, h));
assert_eq!((w, h), (120, 80));
let diff: u64 = exact.iter().zip(&near).map(|(a, b)| u64::from(a.abs_diff(*b))).sum();
let mean = diff as f64 / exact.len() as f64;
assert!(mean <= 4.0, "mean difference {mean}");
// Lower quality, smaller file.
let low = export(&mut s, json!({"lossless": false, "quality": 10})).0;
let high = export(&mut s, json!({"lossless": false, "quality": 95})).0;
assert_eq!(webp_chunks(&low), [*b"VP8 "]);
assert!(low.len() < high.len(), "{} vs {} bytes", low.len(), high.len());
for q in [0, 100] {
assert_eq!(webp_chunks(&export(&mut s, json!({"lossless": false, "quality": q})).0), [*b"VP8 "], "quality {q}");
}
}
#[test]
fn lossy_webp_keeps_translucent_pixels() {
let mut s = Session::new();
s.execute("file.new", &json!({"width": 30, "height": 20})).unwrap();
s.execute("shape.rectangle", &json!({"x": 2, "y": 2, "width": 10, "height": 10})).unwrap();
let r = s.execute("document.export", &json!({"format": "webp"})).unwrap();
let file = b64(&r);
assert_eq!((&file[..4], &file[8..12], &file[12..16]), (&b"RIFF"[..], &b"WEBP"[..], &b"VP8L"[..]), "lossless bitstream");
assert_eq!(r["warnings"], json!([]));
let r = s.execute("document.export", &json!({"format": "webp", "lossless": false, "quality": 60, "background": "black"})).unwrap();
assert_eq!(&b64(&r)[12..16], b"VP8L");
assert!(r["warnings"][0].as_str().unwrap().contains("lossless"), "{r}");
assert_eq!(
craft_image_codecs::decode(&b64(&r))
.map(|__cimg| {
let (__w, __h) = __cimg.dimensions();
match (__cimg.layout(), __cimg.sample_type()) {
(craft_image_codecs::ChannelLayout::Gray, craft_image_codecs::SampleType::U8) => {
image::DynamicImage::ImageLuma8(image::GrayImage::from_raw(__w, __h, __cimg.into_data()).unwrap())
}
(craft_image_codecs::ChannelLayout::GrayA, craft_image_codecs::SampleType::U8) => {
image::DynamicImage::ImageLumaA8(image::GrayAlphaImage::from_raw(__w, __h, __cimg.into_data()).unwrap())
}
(craft_image_codecs::ChannelLayout::Rgb, craft_image_codecs::SampleType::U8) => {
image::DynamicImage::ImageRgb8(image::RgbImage::from_raw(__w, __h, __cimg.into_data()).unwrap())
}
_ => image::DynamicImage::ImageRgba8(image::RgbaImage::from_raw(__w, __h, __cimg.to_rgba8()).unwrap()),
}
})
.unwrap()
.to_rgba8()
.get_pixel(29, 19)
.0,
[0, 0, 0, 255]
);
s.execute("shape.rectangle", &json!({"x": 0, "y": 0, "width": 20, "height": 20})).unwrap();
s.execute("paint.setFill", &json!({"color": "#0000ff"})).unwrap();
s.execute("transparency.set", &json!({"opacity": 50})).unwrap();
let file = |s: &mut Session, lossless: bool| b64(&s.execute("document.export", &json!({"format": "webp", "lossless": lossless})).unwrap());
let (lossless, lossy) = (file(&mut s, true), file(&mut s, false));
assert_eq!(webp_chunks(&lossy), [*b"VP8X", *b"ALPH", *b"VP8 "]);
let ((w, h, exact), (lw, lh, near)) = (rgba(&lossless), rgba(&lossy));
assert_eq!((lw, lh), (w, h));
let at = |px: &[u8], x: u32, y: u32| -> [u8; 4] {
let i = 4 * (y * w + x) as usize;
[px[i], px[i + 1], px[i + 2], px[i + 3]]
};
// The alpha is written exactly: half covered under the rectangle, clear past it.
let alphas = |px: &[u8]| px.chunks(4).map(|p| p[3]).collect::<Vec<u8>>();
assert_eq!(alphas(&near), alphas(&exact));
assert!((120..=135).contains(&at(&near, 5, 5)[3]), "{:?}", at(&near, 5, 5));
assert_eq!(at(&near, 28, 10)[3], 0);
}
#[test]
fn webp_quality_out_of_its_range_is_refused() {
let mut s = varied_art();
for q in [json!(101), json!(255), json!(256), json!(-1), json!(60.5), json!("high"), json!(true)] {
let p = json!({"format": "webp", "lossless": false, "quality": q});
let e = s.execute("document.export", &p).unwrap_err().to_string();
assert!(e.contains("quality"), "{q}: {e}");
// In Export for Screens too, in a row or in the format's settings.
let row = json!({"formats": [{"format": "webp", "lossless": false, "quality": q}]});
assert!(s.execute("document.exportForScreens", &row).is_err(), "{q}");
let settings = json!({"formats": [{"format": "webp"}], "settings": {"webp": {"lossless": false, "quality": q}}});
assert!(s.execute("document.exportForScreens", &settings).is_err(), "{q}");
}
// A lossless file refuses it as well: the value is not a WebP quality.
assert!(s.execute("document.export", &json!({"format": "webp", "quality": 101})).is_err());
let r = s.execute("document.exportForScreens", &json!({"formats": [{"format": "webp", "lossless": false, "quality": 100}]})).unwrap();
let file = b64(&r["files"][0]);
assert_eq!(webp_chunks(&file), [*b"VP8 "]);
}
#[test]
+14 -6
View File
@@ -1,6 +1,6 @@
//! Raster export: render a document region with [`RasterExportOptions`] (resolution, background,
//! anti-aliasing) and encode it as PNG ([`png`]: resolution in `pHYs`, Adam7 interlacing), JPEG
//! ([`jpeg`]: RGB, CMYK or grey, progressive, resolution and colour profile), lossless WebP, or
//! ([`jpeg`]: RGB, CMYK or grey, progressive, resolution and colour profile), lossless or lossy WebP, or
//! a palette image ([`quantize`]) as PNG-8 or [`gif`], [`tiff`] (RGB, CMYK or grey, LZW, either byte
//! order, the profile), [`bmp`] (1–32 bits, RLE) or [`tga`]; [`web`] adds what Save for Web optimises
//! further (web snap, colour table edits, lossy GIF, comments); [`psd`] writes layered bitmaps.
@@ -49,8 +49,10 @@ pub struct RasterExportOptions {
pub anti_alias: AntiAlias,
/// PNG, PNG-8: Adam7 interlacing; GIF: interlaced rows.
pub interlaced: bool,
/// JPEG quality 0–100.
/// JPEG quality 0–100, and lossy WebP's.
pub quality: u8,
/// WebP: lossless (`true`), or lossy at [`Self::quality`].
pub webp_lossless: bool,
/// JPEG colour model, coding and profile.
pub jpeg: jpeg::JpegOptions,
/// PNG-8 and GIF: the colour reduction (also BMP's at 1, 4 and 8 bits).
@@ -76,6 +78,7 @@ impl Default for RasterExportOptions {
anti_alias: AntiAlias::Art,
interlaced: false,
quality: 90,
webp_lossless: true,
jpeg: jpeg::JpegOptions::default(),
palette: quantize::PaletteOptions::default(),
tiff: tiff::TiffOptions::default(),
@@ -125,7 +128,7 @@ impl RasterExportOptions {
};
jpeg::encode(&px, img.width, img.height, self.quality, Some(self.ppi), &self.jpeg)
}
RasterFormat::WebP => webp(img),
RasterFormat::WebP => webp(img, (!self.webp_lossless).then_some(self.quality)),
RasterFormat::Png8 | RasterFormat::Gif => {
let ix = quantize::quantize(&img.to_straight(), img.width, img.height, &self.palette);
match format {
@@ -184,8 +187,9 @@ pub fn on_white(p: &[u8; 4]) -> [u8; 3] {
[0, 1, 2].map(|i| ((u32::from(p[i]) * a + 255 * (255 - a) + 127) / 255) as u8)
}
/// Lossless WebP.
pub(crate) fn webp(img: &Rendered) -> Result<Vec<u8>, String> {
/// WebP: lossless (`VP8L`) when `lossy_quality` is `None`, else lossy (`VP8 `, with an `ALPH`
/// chunk when some pixels are not opaque) at that quality 0–100.
pub(crate) fn webp(img: &Rendered, lossy_quality: Option<u8>) -> Result<Vec<u8>, String> {
let src = craft_image_codecs::Image::from_raw(
img.width,
img.height,
@@ -194,7 +198,11 @@ pub(crate) fn webp(img: &Rendered) -> Result<Vec<u8>, String> {
img.to_straight(),
)
.map_err(|e| format!("WebP encoding failed: {e}"))?;
let opts = craft_image_codecs::EncodeOptions { webp_lossless: true, ..craft_image_codecs::EncodeOptions::default() };
let opts = craft_image_codecs::EncodeOptions {
webp_lossless: lossy_quality.is_none(),
webp_quality: lossy_quality.unwrap_or(100).min(100),
..craft_image_codecs::EncodeOptions::default()
};
craft_image_codecs::encode(&src, craft_image_codecs::Format::WebP, &opts).map_err(|e| format!("WebP encoding failed: {e}"))
}
+34
View File
@@ -202,6 +202,40 @@ fn backgrounds_are_opaque_or_transparent() {
assert_eq!(webp.get_pixel(0, 0).0, [0, 0, 0, 255]);
}
/// The chunk types of RIFF WebP file `file`, in order.
fn webp_chunks(file: &[u8]) -> Vec<[u8; 4]> {
assert_eq!((&file[..4], &file[8..12]), (&b"RIFF"[..], &b"WEBP"[..]));
let mut chunks = Vec::new();
let mut at = 12;
while at + 8 <= file.len() {
let len = u32::from_le_bytes([file[at + 4], file[at + 5], file[at + 6], file[at + 7]]) as usize;
chunks.push([file[at], file[at + 1], file[at + 2], file[at + 3]]);
at += 8 + len + len % 2;
}
chunks
}
/// Lossy WebP is a `VP8 ` picture; transparent pixels stay transparent through an `ALPH` chunk
/// in a `VP8X` file, and opaque art stays opaque.
#[test]
fn lossy_webp_keeps_transparent_pixels_transparent() {
let d = circle_doc();
let lossless = Renderer::new().export_region(&d, d.artboards[0].rect, RasterFormat::WebP, &RasterExportOptions::default()).unwrap();
assert_eq!(webp_chunks(&lossless), [*b"VP8L"], "lossless by default");
let o = RasterExportOptions { webp_lossless: false, quality: 75, ..Default::default() };
let file = Renderer::new().export_region(&d, d.artboards[0].rect, RasterFormat::WebP, &o).unwrap();
assert_eq!(webp_chunks(&file), [*b"VP8X", *b"ALPH", *b"VP8 "]);
let img = export(&d, RasterFormat::WebP, &o);
assert_eq!(img.dimensions(), (40, 30));
assert_eq!(img.get_pixel(0, 0)[3], 0, "a corner outside the circle");
let middle = img.get_pixel(20, 15);
assert!(middle[3] == 255 && middle[0] < 24, "{middle:?}");
// Opaque art on a background is a plain `VP8 ` file.
let opaque = RasterExportOptions { background: Some([255; 3]), ..o };
let file = Renderer::new().export_region(&d, d.artboards[0].rect, RasterFormat::WebP, &opaque).unwrap();
assert_eq!(webp_chunks(&file), [*b"VP8 "]);
}
/// #787: translucent art over opaque art (or a background) stays exactly opaque, its anti-aliased
/// edges too, so the file is written as RGB.
#[test]
+1 -1
View File
@@ -419,7 +419,7 @@ impl Rendered {
}
/// Encode as lossless WebP.
pub fn to_webp(&self) -> Result<Vec<u8>, String> {
encode::webp(self)
encode::webp(self, None)
}
/// Straight-alpha RGBA at (x, y).
pub fn pixel(&self, x: u32, y: u32) -> [u8; 4] {
@@ -189,9 +189,9 @@ pub fn open(app: &mut VectorcraftApp) {
}
/// The options format `id` starts with in Format Settings: the raster options dialogs' defaults
/// (without quality and image maps: the rows choose quality, a map is another file), the SVG
/// Options' first-use ones (without artboards and images: a linked image is another file), or the
/// default PDF preset.
/// (without image maps, a map being another file, and without quality but WebP's: JPEG rows choose
/// their quality), the SVG Options' first-use ones (without artboards and images: a linked image is
/// another file), or the default PDF preset.
fn defaults(app: &VectorcraftApp, id: &str) -> Map<String, Value> {
let mut o = match (id, fileio::format(id)) {
("svg", _) => svg_options::first_use(),
@@ -199,9 +199,12 @@ fn defaults(app: &VectorcraftApp, id: &str) -> Map<String, Value> {
(_, Some(f)) => png_options::defaults(app, f),
_ => Map::new(),
};
for k in ["quality", "imageMap", "useArtboards", "images"] {
for k in ["imageMap", "useArtboards", "images"] {
o.remove(k);
}
if id != "webp" {
o.remove("quality");
}
o
}
+29 -6
View File
@@ -1,6 +1,6 @@
//! The raster export options: PNG Options (resolution, background, anti-aliasing, interlaced),
//! JPEG Options (no transparency; colour model, quality 0–10, method and scans, profile, image
//! map), WebP Options, and PNG-8 and GIF Options (the palette: colour reduction, colours, dither,
//! map), WebP Options (lossless, or lossy at a quality 0–100), and PNG-8 and GIF Options (the palette: colour reduction, colours, dither,
//! transparency and matte), TIFF, BMP and Targa Options ([`super::tiff_bmp_tga`]) and PSD Options
//! ([`super::psd_options`]). Fields
//! are `document.export` params (format, path, artboard choice…); `__`-prefixed ones are the
@@ -39,6 +39,10 @@ const MATTES: [&str; 3] = ["none", "white", "black"];
const MATTE_LABELS: [&str; 4] = ["None", "White", "Black", "Other"];
/// JPEG quality on the dialog's 0–10 scale: the band each step falls in.
const QUALITY_BANDS: [&str; 11] = ["Low", "Low", "Low", "Medium", "Medium", "Medium", "High", "High", "Maximum", "Maximum", "Maximum"];
/// WebP compression labels: `lossless` true, then false.
const WEBP_COMPRESSION_LABELS: [&str; 2] = ["Lossless", "Lossy"];
/// The lossy WebP quality a new export starts with (0–100).
const WEBP_QUALITY: u8 = 90;
/// The dialog kind of a raster format (`pngOptions`, `jpgOptions`, `webpOptions`, `gifOptions`,
/// `png8Options`).
@@ -81,6 +85,9 @@ pub(super) fn defaults(app: &VectorcraftApp, f: &Format) -> Map<String, Value> {
"png" => {
o.insert("interlaced".into(), json!(false));
}
"webp" => {
o.extend([("lossless".into(), json!(true)), ("quality".into(), json!(WEBP_QUALITY))]);
}
"jpg" => {
let model = if cmyk { ColorModel::Cmyk } else { ColorModel::Rgb };
let defaults = jpeg::JpegOptions::default();
@@ -207,11 +214,7 @@ pub(super) fn option_rows(ui: &mut egui::Ui, d: &mut Dialog, id: &str, screens:
}
"jpg" => jpeg_rows(ui, d, &label, screens),
"gif" | "png8" => palette_rows(ui, d, &label),
"webp" => {
ui.label("");
label(ui, tl!("Lossless (lossy WebP isn't available yet)"));
ui.end_row();
}
"webp" => webp_rows(ui, d, &label),
"psd" => psd_options::rows(ui, d, &label),
id => tiff_bmp_tga::rows(ui, d, id, &label),
}
@@ -252,6 +255,26 @@ fn quality_row(ui: &mut egui::Ui, d: &mut Dialog, label: &dyn Fn(&mut egui::Ui,
ui.end_row();
}
/// The WebP Options rows: Lossless or Lossy compression, and the quality 0–100 that Lossy uses
/// (dimmed while Lossless is chosen, keeping its value).
fn webp_rows(ui: &mut egui::Ui, d: &mut Dialog, label: &dyn Fn(&mut egui::Ui, &str) -> egui::Response) {
label(ui, tl!("Compression:"));
let lossless = d.fields.get("lossless").and_then(Value::as_bool).unwrap_or(true);
if let Some(i) = widgets::dropdown(ui, "ro-webp", WEBP_COMPRESSION_LABELS[usize::from(!lossless)], &WEBP_COMPRESSION_LABELS, 150.0) {
d.fields.insert("lossless".into(), json!(i == 0));
}
ui.end_row();
label(ui, tl!("Quality:"));
let mut q = d.f64("quality", f64::from(WEBP_QUALITY)).round().clamp(0.0, 100.0) as u8;
ui.add_enabled_ui(!lossless, |ui| {
if widgets::slider(ui, egui::Slider::new(&mut q, 0..=100)).changed() {
d.fields.insert("quality".into(), json!(q));
}
});
ui.end_row();
}
/// The JPEG method, and its scans when progressive.
fn method_row(ui: &mut egui::Ui, d: &mut Dialog, label: &dyn Fn(&mut egui::Ui, &str) -> egui::Response) {
label(ui, tl!("Method:"));
@@ -101,13 +101,48 @@ fn text_export_options_write_the_stories() {
assert_eq!((path.as_str(), bytes.as_slice()), ("/out/Untitled-1.txt", &b"Hello\r\nthere\r\n"[..]));
}
/// WebP Options: Lossless by default, with the Quality slider disabled; Lossy enables it, and OK
/// writes a lossy file at that quality, without a note.
#[test]
fn webp_options_say_the_file_is_lossless() {
let (mut app, _) = app(1);
fn webp_options_choose_lossless_or_lossy_at_a_quality() {
use crate::widgets::accessibility_tests::tree;
use egui::accesskit::Role;
let quality_disabled = |app: &mut VectorcraftApp| {
let t = tree(|ui| show(app, ui.ctx()));
t.iter().find(|n| n.role() == Role::Slider).expect("the Quality slider").is_disabled()
};
let (mut app, written) = app(1);
app.run("file.exportAs", json!({"format": "webp"})).unwrap();
confirm(&mut app).unwrap();
assert_eq!(kind(&app), Some("webpOptions"));
let d = app.ui.dialog.as_ref().unwrap();
assert_eq!((&d.fields["lossless"], &d.fields["quality"]), (&json!(true), &json!(90)));
assert!(quality_disabled(&mut app), "Quality applies to Lossy");
frame(&mut app);
confirm(&mut app).unwrap();
assert_eq!(&written.borrow()[0].1[12..16], b"VP8L", "lossless by default");
app.run("file.exportAs", json!({"format": "webp"})).unwrap();
confirm(&mut app).unwrap();
set(&mut app, "lossless", json!(false));
set(&mut app, "quality", json!(40));
assert!(!quality_disabled(&mut app), "Lossy enables Quality");
frame(&mut app);
// The dialog's options, as `document.export` takes them.
let mut options = app.ui.dialog.as_ref().unwrap().fields.clone();
options.retain(|k, _| !k.starts_with("__") && k != "path");
let r = confirm(&mut app).unwrap();
assert_eq!(r["warnings"], json!([]), "{r}");
let file = written.borrow().last().unwrap().1.clone();
assert!(file.windows(4).any(|w| w == b"VP8 ") && !file.windows(4).any(|w| w == b"VP8L"), "lossy");
// The file is the one `document.export` writes with those options at quality 40.
let at = |app: &mut VectorcraftApp, q: u8| {
let mut p = options.clone();
p.insert("quality".into(), json!(q));
vectorcraft_format::base64_decode(app.run("document.export", serde_json::Value::Object(p)).unwrap()["dataBase64"].as_str().unwrap()).unwrap()
};
assert_eq!(file, at(&mut app, 40));
assert_ne!(file, at(&mut app, 90));
}
#[test]
+2 -1
View File
@@ -1952,7 +1952,8 @@ font-technology Variable Променливи
Lock Others Заключване на другите
Lock Slices Заключване на фрагментите
Lock Station Point Заключване на базовата точка
Lossless (lossy WebP isn't available yet) Без загуба (загубеният WebP все още не е наличен)
Lossless Без загуба
Lossy Със загуба
Lossy: С загуба:
Low Ниско
lowercase малки букви
Can't render this file because it is too large.
+2 -1
View File
@@ -2825,7 +2825,8 @@ digits Malayalam Malajalam
Hide Video Rulers Sakrij video ravnala
Client-side (.html) Na strani klijenta (.html)
Color Reduction: Smanjenje boja:
Lossless (lossy WebP isn't available yet) Bez gubitaka (WebP s gubicima još nije dostupan)
Lossless Bez gubitaka
Lossy S gubicima
Scans: Skenovi:
Server-side (.map) Na strani servera (.map)
{format} Options Opcije za {format}
Can't render this file because it contains an unexpected character in line 2 and column 73.
+2 -1
View File
@@ -2557,7 +2557,8 @@ digits Malayalam Malaiàlam
Long Lines Línies llargues
Long Strokes Traços llargs
Longest: El més llarg:
Lossless (lossy WebP isn't available yet) Sense pèrdua (el WebP amb pèrdua encara no està disponible)
Lossless Sense pèrdua
Lossy Amb pèrdua
Lossy: Amb pèrdua:
Low Baix
Low Fidelity Photo Foto de baixa fidelitat
Can't render this file because it contains an unexpected character in line 2 and column 73.
+2 -1
View File
@@ -2909,7 +2909,8 @@ digits Malayalam Malajálamské
Hide Video Rulers Skrýt video pravítka
Client-side (.html) Na straně klienta (.html)
Color Reduction: Redukce barev:
Lossless (lossy WebP isn't available yet) Bezeztrátový (ztrátový WebP zatím není k dispozici)
Lossless Bezeztrátový
Lossy Ztrátový
Scans: Průchody:
Server-side (.map) Na straně serveru (.map)
{format} Options Možnosti {format}
Can't render this file because it is too large.
+2 -1
View File
@@ -5376,7 +5376,8 @@ digits Malayalam Malayalam
Hide Video Rulers Skjul videolinealer
Client-side (.html) Klientbaseret (.html)
Color Reduction: Farvereduktion:
Lossless (lossy WebP isn't available yet) Tabsfri (WebP med tab er ikke tilgængelig endnu)
Lossless Tabsfri
Lossy Med tab
Scans: Scanninger:
Server-side (.map) Serverbaseret (.map)
{format} Options Indstillinger for {format}
Can't render this file because it is too large.
+2 -1
View File
@@ -2032,7 +2032,8 @@ file-filter Templates Vorlagen
Lock Others Andere sperren
Lock Slices Slices sperren
Lock Station Point Standpunkt sperren
Lossless (lossy WebP isn't available yet) Verlustfrei (verlustbehaftetes WebP ist noch nicht verfügbar)
Lossless Verlustfrei
Lossy Verlustbehaftet
Lossy: Verlustbehaftet:
Low Niedrig
lowercase kleinbuchstaben
Can't render this file because it is too large.
+2 -1
View File
@@ -3101,7 +3101,8 @@ theme Appearance Εμφάνιση
Lock Grid Κλείδωμα πλέγματος
Lock Others Κλείδωμα υπόλοιπων
Lock Station Point Κλείδωμα σταθερού σημείου
Lossless (lossy WebP isn't available yet) Χωρίς απώλειες (το WebP με απώλειες δεν υποστηρίζεται ακόμη)
Lossless Χωρίς απώλειες
Lossy Με απώλειες
Lossy: Με απώλειες:
lowercase πεζά
LZW Compression Συμπίεση LZW
Can't render this file because it is too large.
+2 -1
View File
@@ -2033,7 +2033,8 @@ font-technology Variable Variables
Lock Others Bloquear otros
Lock Slices Bloquear sectores
Lock Station Point Bloquear punto de estación
Lossless (lossy WebP isn't available yet) Sin pérdida (WebP con pérdida aún no está disponible)
Lossless Sin pérdida
Lossy Con pérdida
Lossy: Con pérdida:
Low Baja
lowercase minúsculas
Can't render this file because it contains an unexpected character in line 2 and column 73.
+2 -1
View File
@@ -2853,7 +2853,8 @@ digits Malayalam Malajalam
Hide Video Rulers Piilota videoviivaimet
Client-side (.html) Asiakaspuoli (.html)
Color Reduction: Värien vähennys:
Lossless (lossy WebP isn't available yet) Häviötön (häviöllinen WebP ei ole vielä käytettävissä)
Lossless Häviötön
Lossy Häviöllinen
Scans: Läpikäynnit:
Server-side (.map) Palvelinpuoli (.map)
{format} Options {format}-asetukset
Can't render this file because it contains an unexpected character in line 2 and column 73.
+2 -1
View File
@@ -2023,7 +2023,8 @@ font-technology Variable Variables
Lock Others Verrouiller les autres
Lock Slices Verrouiller les tranches
Lock Station Point Verrouiller le point d’observation
Lossless (lossy WebP isn't available yet) Sans perte (le WebP avec perte n’est pas encore disponible)
Lossless Sans perte
Lossy Avec perte
Lossy: Avec perte :
Low Faible
lowercase minuscules
Can't render this file because it is too large.
+2 -1
View File
@@ -2096,7 +2096,8 @@
Locked લૉક કરેલું
Long લાંબું
Longest: સૌથી લાંબું:
Lossless (lossy WebP isn't available yet) લોસલેસ (લોસી WebP હજી ઉપલબ્ધ નથી)
Lossless લોસલેસ
Lossy લોસી
Lossy: લોસી:
Luminosity લ્યુમિનોસિટી
Magic Wand મૅજિક વૅન્ડ
Can't render this file because it contains an unexpected character in line 72 and column 5.
+2 -1
View File
@@ -2801,7 +2801,8 @@ antiAlias Sharp शार्प
Long Lines लंबी रेखाएँ
Long Strokes लंबे स्ट्रोक
Longest: सबसे लंबे:
Lossless (lossy WebP isn't available yet) लॉसलेस (लॉसी WebP अभी उपलब्ध नहीं है)
Lossless लॉसलेस
Lossy लॉसी
Lossy: हानि:
Low निम्न
Low Fidelity Photo लो फिडेलिटी फोटो
Can't render this file because it is too large.
+2 -1
View File
@@ -2539,7 +2539,8 @@ file-filter Templates Sablonok
Long Lines Hosszú vonalak
Long Strokes Hosszú vonások
Longest: Leghosszabb:
Lossless (lossy WebP isn't available yet) Veszteségmentes (a veszteséges WebP még nem érhető el)
Lossless Veszteségmentes
Lossy Veszteséges
Lossy: Veszteség:
Low Alacsony
Low Fidelity Photo Kis pontosságú fotó
Can't render this file because it is too large.
+2 -1
View File
@@ -2634,7 +2634,8 @@ digits Malayalam Malayalam
Hide Video Rulers Sembunyikan penggaris video
Client-side (.html) Sisi klien (.html)
Color Reduction: Reduksi warna:
Lossless (lossy WebP isn't available yet) Tanpa kehilangan (WebP lossy belum tersedia)
Lossless Tanpa kehilangan
Lossy Dengan kehilangan
Scans: Pemindaian:
Server-side (.map) Sisi server (.map)
{format} Options Opsi {format}
Can't render this file because it contains an unexpected character in line 2495 and column 5.
+2 -1
View File
@@ -2069,7 +2069,8 @@ file-filter Templates Modelli
Lock Others Blocca altri
Lock Slices Blocca sezioni
Lock Station Point Blocca punto di osservazione
Lossless (lossy WebP isn't available yet) Senza perdita (WebP con perdita non è ancora disponibile)
Lossless Senza perdita
Lossy Con perdita
Lossy: Con perdita:
Low Bassa
lowercase minuscole
Can't render this file because it is too large.
+2 -1
View File
@@ -2326,7 +2326,8 @@ antiAlias Sharp シャープ
Location 場所
Location: 位置:
Lock (⌘2) ロック (⌘2)
Lossless (lossy WebP isn't available yet) ロスレス (非可逆 WebP は未対応)
Lossless ロスレス
Lossy 非可逆
Lossy: 圧縮率:
Luminosity 輝度
Magic Wand Options 自動選択オプション
Can't render this file because it is too large.
+2 -1
View File
@@ -4690,7 +4690,8 @@ digits Malayalam მალაიალამური
Hide Video Rulers ვიდეოს სახაზავების დამალვა
Client-side (.html) კლიენტის მხარე (.html)
Color Reduction: ფერების შემცირება:
Lossless (lossy WebP isn't available yet) უდანაკარგო (დანაკარგიანი WebP ჯერ მიუწვდომელია)
Lossless უდანაკარგო
Lossy დანაკარგიანი
Scans: სკანირებები:
Server-side (.map) სერვერის მხარე (.map)
{format} Options {format}: პარამეტრები
Can't render this file because it is too large.
+2 -1
View File
@@ -2316,7 +2316,8 @@ antiAlias Sharp 날카롭게
Location 위치
Location: 위치:
Lock (⌘2) 잠금 (⌘2)
Lossless (lossy WebP isn't available yet) 무손실 (손실 WebP는 아직 지원되지 않음)
Lossless 무손실
Lossy 손실
Lossy: 손실 압축:
Luminosity 광도
Magic Wand Options 마술봉 옵션
Can't render this file because it is too large.
+2 -1
View File
@@ -3251,7 +3251,8 @@ digits Malayalam Malayalam
Hide Video Rulers Videolinialen verbergen
Client-side (.html) Client-side (.html)
Color Reduction: Kleurreductie:
Lossless (lossy WebP isn't available yet) Verliesvrij (WebP met verlies is nog niet beschikbaar)
Lossless Verliesvrij
Lossy Met verlies
Scans: Scans:
Server-side (.map) Server-side (.map)
{format} Options Opties voor {format}
Can't render this file because it is too large.
+2 -1
View File
@@ -2822,7 +2822,8 @@ digits Malayalam Malajalam
Hide Video Rulers Ukryj linijki wideo
Client-side (.html) Po stronie klienta (.html)
Color Reduction: Redukcja kolorów:
Lossless (lossy WebP isn't available yet) Bezstratny (stratny WebP nie jest jeszcze dostępny)
Lossless Bezstratny
Lossy Stratny
Scans: Skany:
Server-side (.map) Po stronie serwera (.map)
{format} Options Opcje: {format}
Can't render this file because it is too large.
+2 -1
View File
@@ -1713,7 +1713,8 @@ antiAlias Sharp Nítido
Artboard Guides with Cmd/Ctrl + Ruler Drag Guias de Prancheta com Cmd/Ctrl + Arrastar da Régua
Lock Slices Bloquear Fatias
Lock Station Point Bloquear Ponto de Estação
Lossless (lossy WebP isn't available yet) Sem Perdas (WebP com perdas ainda não está disponível)
Lossless Sem Perdas
Lossy Com Perdas
Lossy: Com Perdas:
Luminosity Luminosidade
Magic Wand Varinha Mágica
Can't render this file because it is too large.
+2 -1
View File
@@ -2060,7 +2060,8 @@ file-filter Templates Шаблоны
Lock Others Заблокировать остальные
Lock Slices Заблокировать фрагменты
Lock Station Point Заблокировать точку стояния
Lossless (lossy WebP isn't available yet) Без потерь (WebP с потерями пока недоступен)
Lossless Без потерь
Lossy С потерями
Lossy: С потерями:
Low Низкая
lowercase строчные
Can't render this file because it is too large.
+2 -1
View File
@@ -1968,7 +1968,8 @@ font-technology Variable Variabla
Lock Others Lås övriga
Lock Slices Lås skivor
Lock Station Point Lås betraktarpunkt
Lossless (lossy WebP isn't available yet) Förlustfri (förlustbehäftad WebP är inte tillgänglig än)
Lossless Förlustfri
Lossy Förlustbehäftad
Lossy: Förlust:
Low Låg
lowercase gemener
Can't render this file because it is too large.
+2 -1
View File
@@ -1853,7 +1853,8 @@ font-technology Variable Değişken
Lock Others Diğerlerini Kilitle
Lock Slices Dilimleri Kilitle
Lock Station Point Kilit İstasyon Noktası
Lossless (lossy WebP isn't available yet) Kayıpsız (kayıplı WebP henüz mevcut değil)
Lossless Kayıpsız
Lossy Kayıplı
Lossy: Kayıplı:
Low Düşük
lowercase küçük harf
Can't render this file because it is too large.
+2 -1
View File
@@ -2063,7 +2063,8 @@ file-filter Templates Шаблони
Lock Others Заблокувати решту
Lock Slices Заблокувати фрагменти
Lock Station Point Заблокувати точку стояння
Lossless (lossy WebP isn't available yet) Без втрат (WebP із втратами поки недоступний)
Lossless Без втрат
Lossy Із втратами
Lossy: Із втратами:
Low Низька
lowercase малі
Can't render this file because it is too large.
+2 -1
View File
@@ -2372,7 +2372,8 @@ digits Hindi Hindi
Long Lines Nét dài
Long Strokes Nét vẽ dài
Longest: Dài nhất:
Lossless (lossy WebP isn't available yet) Không mất dữ liệu (WebP mất dữ liệu chưa hỗ trợ)
Lossless Không mất dữ liệu
Lossy Mất dữ liệu
Lossy: Mất dữ liệu:
Low Thấp
lowercase chữ thường
Can't render this file because it contains an unexpected character in line 205 and column 5.
+2 -1
View File
@@ -1939,7 +1939,8 @@ file-filter Templates 模板
Artboard Guides with Cmd/Ctrl + Ruler Drag 按住 Cmd/Ctrl 从标尺拖动创建画板参考线
Lock Slices 锁定切片
Lock Station Point 锁定基准点
Lossless (lossy WebP isn't available yet) 无失真 (尚未提供有失真的 WebP)
Lossless 无失真
Lossy 有失真
Lossy: 有损:
Low 低
lowercase 小写
Can't render this file because it is too large.
+2 -1
View File
@@ -3177,7 +3177,8 @@ liquify-list-end {0}, {1} {0}和{1}
Lock Others 鎖定其他
Lock Slices 鎖定切片
Lock Station Point 鎖定基準點
Lossless (lossy WebP isn't available yet) 無失真 (尚未提供有失真的 WebP)
Lossless 無失真
Lossy 有失真
Lossy: 失真度:
Low 低
lowercase 全部小寫
Can't render this file because it is too large.
+12 -9
View File
@@ -190,20 +190,23 @@ mod tests {
assert_eq!(app.ui.status_notes, Some((app.ui.status.clone(), notes)));
}
/// An export whose encoder notes an option it didn't apply (lossy WebP) before what the file
/// loses (type in a font that isn't installed): the status bar names what the file loses, and
/// the hover lists it first.
/// An export whose encoder notes what an option left out (the fill hatches that
/// `includeHatches: false` leaves out of a DXF drawing) and what the file loses (a see-through
/// rectangle that DXF 2000 writes opaque): the status bar names what the file loses, and the
/// hover lists the option's note last.
#[test]
fn an_export_names_what_the_file_loses_before_a_note_on_the_options() {
let (mut app, _) = app();
app.run("file.new", json!({"width": 100, "height": 100})).unwrap();
app.run("text.create", json!({"x": 5, "y": 20, "text": "Ab", "font": "Nonexistent Sans Probe"})).unwrap();
let r = export(&mut app, Some("webp"), Some("/out/d.webp".into()), &json!({"lossless": false})).unwrap();
app.run("shape.rectangle", json!({"x": 10, "y": 10, "width": 30, "height": 20})).unwrap();
app.run("object.setProps", json!({"opacity": 50})).unwrap();
let r = export(&mut app, Some("dxf"), Some("/out/d.dxf".into()), &json!({"version": "2000", "includeHatches": false})).unwrap();
let notes = notes_of(&r);
assert_eq!(notes.len(), 2, "{r}");
assert!(notes[0].contains("Nonexistent Sans Probe"), "{r}");
assert!(notes[1].starts_with("lossy WebP"), "{r}");
assert_eq!(app.ui.status, exported_with_notes("/out/d.webp", 2, &notes[0]));
let Some((option, losses)) = notes.split_last() else { panic!("no notes: {r}") };
assert!(option.starts_with("fill hatches are left out"), "{r}");
assert!(losses.iter().any(|n| n.starts_with("transparency needs DXF 2004")), "{r}");
assert!(!losses.iter().any(|n| n.starts_with("fill hatches")), "{r}");
assert_eq!(app.ui.status, exported_with_notes("/out/d.dxf", notes.len(), &notes[0]));
assert_eq!(app.ui.status_notes, Some((app.ui.status.clone(), notes)));
}
+1 -1
View File
@@ -299,7 +299,7 @@ Names in the editing data that aren't UTF-8 (layers, objects, artboards, colors,
| PSD | open, place, export | yes (open: layers as layers, or the merged image with `layers: false`; place: merged image, or the layers embedded as a group of objects with `layers: true`; the merged image comes in clipped by the file's clipping path; every mode and depth; `.psd` and `.pdd`) | yes (layered, max editability, point type as editable type layers with `preserveText`; `tests_psd.rs`) | PSD Import Options on File › Open and on File › Place without Link (Convert Layers to Objects, Flatten Layers to a Single Image, Import Hidden Layers, Import Slices; `tests_psdlayers.rs`, `dialogs/psd_import.rs`); slices (image resource 1050, version 6 and the version 7 and 8 descriptor) open and embed as user slices with `importSlices` (`tests_psdslices.rs`); layer comps aren't read; the embedded ICC profile's tags are 4-byte aligned (#1584) |
| PSB | open | yes (layers as layers, or the merged image; the merged image comes in clipped by the file's clipping path) | no | |
| PNG / JPEG / GIF / BMP / TIFF / Targa | open, place, export | yes (PNG: `.png` and `.pns`; BMP: `.bmp`, `.dib` and `.rle`; Targa: `.tga`, `.vda`, `.icb` and `.vst`, raw or run-length encoded, with a 16-bit file's one-bit alpha) | yes; TIFF is also selectable in Export for Screens and Asset Export with its existing options | Targa: `tests_tiffbmp.rs`, `tests/links.rs`; TIFF: grayscale with an alpha channel or other extra channels reads (#1466 in part), and so do files that store each channel as its own plane (PlanarConfiguration 2), CMYK ones with their ink amounts, and 1-bit files compressed with CCITT Group 3 (Compression 2 and 3, one- and two-dimensional rows); the ICC profiles embedded in JPEG and TIFF have 4-byte aligned tags (#1584); PNG export marks its colours as sRGB (`embedIcc`, an `sRGB` chunk; no ICC profile is embedded, #2221) |
| WebP | export (Export for Screens) | yes | yes (lossless only; lossy written lossless with a warning) | |
| WebP | export (Export for Screens) | yes | yes (lossless by default; `lossless: false` writes lossy WebP at `quality` 0–100, default 90) | lossy files are `VP8 `, with an `ALPH` chunk when some pixels are not opaque; `tests_text.rs` |
| JPEG XL `.jxl` | — | yes (first frame; 16-bit and floating-point samples as 8 bits, alpha kept; CMYK refused) | no | decoded with jxl-oxide; the size is checked from the header before decoding; container Exif resolution sizes opened and placed images; tests in `crates/engine/src/cmd/fileio/tests_jxlread.rs` and `crates/engine/tests/import_fuzz.rs` |
| HEIC / HEIF | open, place | yes (HEVC-coded still images: single pictures and grids of tiles, 8 to 10 bits, with an alpha image; image sequences, other codings and grids of cropped tiles are refused) | no | `.heic`, `.heif`; decoded by heic-rs in the engine's default `heif` feature (a build without it refuses the files with a message); the container's rotation, mirror and crop are applied; without an `nclx` box the HEVC stream's video signal type gives the matrix and range; an RGB ICC profile, or Display P3 with the sRGB curve named by an `nclx` box or, without a color box, by the stream, is converted to sRGB; EXIF resolution tags size the image, or 72 ppi; bounded decoding; `tests_heifread.rs` |
| PCX | open, place | yes (1 bit in the header palette's first two colors, black and white without them; 1 bit in two to four planes and 4 bits with up to 16 colors; 2 bits in the CGA colors the header's CGA palette settings pick; 8 bits with the 256-color palette, gray without one; 24-bit color in three planes) | no | the header's HDpi and VDpi size the image; a file of another depth or plane count, cut short or past the pixel allowance is refused with a message; tests in `crates/engine/src/cmd/fileio/tests_pcxread.rs` and `crates/engine/tests/import_fuzz.rs` |
+6
View File
@@ -1273,6 +1273,12 @@ pixels per point, and the file stores the resolution that results, as with `ppi`
either one wins over `ppi` and `scale`. A value that is not a positive number is refused. Export for Screens rows keep
their own size (`scale: "512w"`).
WebP is lossless by default (`lossless: true`). `{"format": "webp", "lossless": false, "quality": 60}` writes a lossy
WebP file: `quality` runs from 0 to 100 (default 90, VectorCraft's own value), and a higher value keeps more detail in
a larger file. A lossy file keeps the alpha exactly when some pixels are not opaque. A WebP `quality` above 100, or one
that is not a whole number, is refused; a lossless file ignores `quality`. Export for Screens takes both in a WebP row
or in `settings.webp`.
`shape.ellipse` (and `draw_shape` with `shape: "ellipse"`) takes `anchors`, the number of smooth anchors (default 4).
Without it, or at 4, it draws a live ellipse. Any other count from 2 to 1000 draws a closed plain path with that many
anchors spaced evenly by angle, clockwise from the left one and fitted to `width` × `height`. The Ellipse dialog (a
+2 -1
View File
@@ -632,7 +632,7 @@ since 2026-10-01.
- **Clipped bottom-bar text (#6622):** A Help Bar hint wider than the window, such as the Dimension tool's hint in an 800-point window, ends in an ellipsis, as the status message does. In a narrow status bar the tool name ends in an ellipsis and leaves the status message its room. Resting the pointer on a clipped hint, tool name or message shows the full text in a tooltip that wraps within the window. Text that fits shows no tooltip, and screen readers receive the full text. Scores and estimates are unchanged.
- **Notes of an open in the status bar:** After File › Open the status message names the first note that says reading the file left something out (the notes that make Save ask before writing over the file), else the first note, and counts them all. With several notes, resting the pointer on the message lists them in that order, as many as fit in the window and at most 30, then how many more. Screen readers receive the list after the message. Scores and estimates are unchanged.
- **Notes of a save or an export in the status bar:** After Save, Save As, Save a Copy, Save as Template, Save a Timestamped Copy, Save as PDF, Export As, Export Selection, Export for Screens, Asset Export, Save for Web, Preview in Browser, Save for Office Documents, Text Export Options, a print to a file or the CSS Properties panel's export, the status message names the first note and counts them all. With several notes, resting the pointer on the message lists them in the order the reply gives them (a save's notes start with what the format loses), as it lists an open's notes. Scores and estimates are unchanged.
- **What a save or an export loses, named first:** Each writer marks its notes as a loss (something of the document the file leaves out or writes differently) or a note on the options (an option it didn't apply or applied another way while the art reaches the file as it looks, or something an option turns off). The replies of the save and export commands list the losses first, each kind in the order given, across every file an export writes. The status message after a save or an export then names a loss when there is one: an export to lossy WebP of type in a font that isn't installed names the fallback-font note instead of the lossy WebP note. A print to a file and the print preview list theirs the same way: art outside the imageable area, type in a fallback font and transparency flattened for PostScript come before notes such as a fixed flatness that isn't written or copies per sheet that don't fit. Scores and estimates are unchanged.
- **What a save or an export loses, named first:** Each writer marks its notes as a loss (something of the document the file leaves out or writes differently) or a note on the options (an option it didn't apply or applied another way while the art reaches the file as it looks, or something an option turns off). The replies of the save and export commands list the losses first, each kind in the order given, across every file an export writes. The status message after a save or an export then names a loss when there is one: a WebP export of type in a font that isn't installed, given an option WebP doesn't read (`interlaced`), names the fallback-font note instead of the note on that option. A print to a file and the print preview list theirs the same way: art outside the imageable area, type in a fallback font and transparency flattened for PostScript come before notes such as a fixed flatness that isn't written or copies per sheet that don't fit. Scores and estimates are unchanged.
- **Canvas review follow-up:** Cached canvas dimensions match the renderer limit before cache-key creation, view construction and worker submission. Controlled-worker regression checks oversized width and height, high DPI and the render transform without allocating oversized images. Scores and estimates are unchanged.
- **Cached canvas frames during viewport changes:** Cached screen textures use their own raster dimensions and pixels-per-point when reprojected. `canvas::tests::cached_frames_keep_their_scale_during_resize_rotation_and_dpi_changes` holds the worker and checks every UV corner against the cached render transform, including isolated viewport-only resize at zero/30-degree rotation, fractional raster dimensions, zoom/pan, changed rotation, monitor-DPI changes in both directions, Pixel Preview and replacement-frame delivery. The contributor rebuilt and confirmed the original resize issue is fixed with their own artwork on 2026-10-19; the subsequent upstream rebase is checked by regressions and full CI. The artwork stays local. Scores and estimates are unchanged.
@@ -703,6 +703,7 @@ since 2026-10-01.
- **Escape in more tool drags:** Escape during an Anchor Point drag, a Mesh tool drag, a Direct Selection drag of a mesh point, a corner widget or the brackets of type on a path, or a Shape Builder drag cancels it: the art goes back to how the press found it, no undo step is added, the release does nothing, and the tool stays chosen. Escape during a Measure tool drag brings back the measurement before it. Regression tests: `escape_cancels_*` in `draw2/anchor/tests.rs`, `meshedit.rs`, `direct/tests.rs`, `builder/tests.rs` and `xform/measure.rs`, and `escape_cancels_an_anchor_point_mesh_shape_builder_or_measure_drag` in `tests/toolescape.rs`.
- **Shift-click on corner widgets (#5188):** with Direct Selection, when every corner of a path is selected (the path selected whole), a Shift-click on a corner widget picks that corner alone, so the next drag rounds just it. The other corners' widgets then hide; a Shift-click on another corner's anchor adds that corner and shows its widget, and a Shift-click on a showing widget deselects its corner. Adding a corner by Shift-clicking its widget while it is hidden stays open (#1232). Corner widgets are chosen by clicking one and Shift-clicking the others ([Logos By Nick, rounded corners in Illustrator](https://logosbynick.com/?p=15787)). Test: `corners::tests::a_shift_click_on_a_widget_of_a_whole_path_picks_its_corner`.
- **TIFF in screen and asset export:** both format menus expose the existing TIFF encoder and Format Settings. Headless UI regressions choose TIFF and check scaled dimensions, artboard selection, filenames, encoding options, saved settings and collected-asset output. Public reference: [Export for Screens](https://helpx.adobe.com/illustrator/desktop/save-and-export/export-files-to-different-formats/export-for-screens.html), updated 2026-09-28, lists TIFF for both artboards and assets. Adobe staff [confirmed support in 30.2.1](https://illustrator.uservoice.com/forums/333657-illustrator-desktop-feature-requests/suggestions/49081034-add-tiff-format-into-export-for-screens-assets-d) on 2026-02-19; the older 2025 Collect assets guide omits TIFF.
- **Lossy WebP with a Quality setting:** WebP Options has a Compression menu (Lossless, Lossy) and a Quality slider from 0 to 100 that is enabled for Lossy. Lossy writes a `VP8 ` WebP file, with an `ALPH` chunk that keeps the alpha exactly when some pixels are not opaque. `document.export`, `document.serialize` and Export for Screens take `lossless: false` with `quality` (default 90, VectorCraft's own value), in a format row or in `settings.webp`; Format Settings for WebP keeps both. Lossless stays the default, and a quality above 100 or one that is not a whole number is refused. Public reference: [export file format options](https://helpx.adobe.com/illustrator/desktop/save-and-export/export-files-to-different-formats/export-file-format-options-in-illustrator.html) describes Lossless and Lossy WebP and a Quality setting for Lossy (`webp_is_lossless_by_default_and_lossy_when_asked`, `lossy_webp_keeps_translucent_pixels`, `webp_quality_out_of_its_range_is_refused` in `crates/engine/src/cmd/fileio/tests_text.rs`, `webp_options_choose_lossless_or_lossy_at_a_quality`).
- **Export for Screens of the selected artboards:** while the Artboard tool is in use, File › Export › Export for Screens… (`file.exportForScreens`) opens with the artboards the tool has selected checked on its Artboards tab, and Export Artboard writes only those. Shift-clicks on the canvas, or Shift- or Ctrl/Cmd-clicks on the Artboards panel's rows, select several. The other fields show the settings the document last exported with. With another tool in use, the dialog takes its artboard choice from those settings too. Public reference: [Export selected artboards](https://helpx.adobe.com/illustrator/desktop/create-manage-artboards/organize-manage-artboards/export-artboards.html).
- **Effects in Export Selection and asset crops:** File › Export Selection, Asset Export, Export for Screens' Assets tab and CSS Properties' rasterized art crop each object to the bounds the renderer measures for what it draws: drop shadows, glows, geometry effects such as Offset Path, a group's own effects and the effects in a symbol's art. A brushed path is cropped to its visual bounds, and a Shaper group is cropped to the art it shows. `assets.list` reports the same crop. Engine tests export a square with each effect, a group with a shadow and an asset with a shadow, and check that the effect is inside the image. Public reference: a [Community Expert answer](https://community.adobe.com/t5/illustrator-discussions/exporting-assets-adds-transparent-borders/m-p/10708713/highlight/true) traces the extra area of exported assets to the raster effects' area (Document Raster Effects Settings › Add Around Object).