M4.90: Save for Web (Legacy) previews and saves optimised GIF, JPEG, PNG-8 and PNG-24 images, slices and HTML

File > Export > Save for Web (Legacy) (Ctrl/Cmd+Alt+Shift+S) opens a dialog with Original,
Optimized, 2-Up and 4-Up views showing each file's size and download time, and settings for
colour reduction, colours, dither, transparency and matte, interlacing, web snap, lossy GIF,
JPEG quality, the colour table (lock, map to transparent, web shift, sort), image size and
anti-aliasing, Clip to Artboard, sRGB, metadata, slices (all or selected), HTML output and
presets. Preview in Browser opens the HTML page.

Engine: document.exportForWeb, document.exportForWeb.preview (its byte count is the size of
the file Save writes), webExport.settings and webExport.presets.list/save/delete. Saved presets
and the remembered settings are stored in Prefs. Render: quantize_locked, and encode::web for
web snap, colour table edits, lossy GIF and GIF/JPEG comments. PNG files get an sRGB chunk.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
bflatastic
2026-10-05 15:24:51 +07:00
co-authored by Claude Opus 5.5
parent b578c32f4d
commit c6450f6f70
20 changed files with 2959 additions and 36 deletions
+2 -2
View File
@@ -125,8 +125,8 @@ fn polygon(path: &kurbo::BezPath, tolerance: f64) -> Option<Vec<kurbo::Point>> {
(pts.len() >= 3).then_some(pts)
}
/// Escape text for an HTML attribute.
fn attr(s: &str) -> String {
/// Escape text for an HTML attribute (or element text).
pub(crate) fn attr(s: &str) -> String {
s.chars().filter(|c| !c.is_control()).fold(String::with_capacity(s.len()), |mut o, c| {
match c {
'&' => o.push_str("&amp;"),
+1 -1
View File
@@ -25,7 +25,7 @@ pub mod dxfimport;
mod encode;
pub mod eps;
mod export;
mod imagemap;
pub(crate) mod imagemap;
mod load;
mod metafile;
mod native;
+2
View File
@@ -64,6 +64,7 @@ pub(crate) mod typecmd;
mod typemenu;
pub(crate) mod views;
pub mod wand;
pub mod webexport;
mod xform;
use serde::Serialize;
@@ -233,6 +234,7 @@ pub fn command_specs() -> &'static [CommandSpec] {
v.extend(print::specs());
v.extend(recovery::specs());
v.extend(fileio::dxfimport::specs());
v.extend(webexport::specs());
v
})
}
+1 -1
View File
@@ -209,7 +209,7 @@ fn selected(s: &Session) -> Result<Vec<NodeId>> {
Ok(selected_slices(&st.doc, &st.selection))
}
fn selected_slices(d: &Document, sel: &vectorcraft_doc::Selection) -> Vec<NodeId> {
pub(crate) fn selected_slices(d: &Document, sel: &vectorcraft_doc::Selection) -> Vec<NodeId> {
let objects = sel.objects.iter().filter(|id| d.node(**id).is_some_and(|n| n.slice.is_some()));
dedup(sel.slices.iter().chain(objects).copied().collect())
}
File diff suppressed because it is too large Load Diff