Skip to content

PhotoCraft: An open-source, photo editor written by scratch in pure Rust

Export As: Resample menu, incl. Nearest Neighbor (#5838)

David Manna8db6dd10049
diff --git a/crates/doc/src/vector.rs b/crates/doc/src/vector.rs
index f36df185a..5caca323b 100644
--- a/crates/doc/src/vector.rs
+++ b/crates/doc/src/vector.rs
@@ -192,7 +192,8 @@ pub struct VectorMask {
pub linked: bool,
/// Density `0..=1` (Properties panel), like [`crate::LayerMask::density`].
pub density: f32,
- /// Feather radius in px (stored; rendered unfeathered for now).
+ /// Feather radius in px (Properties panel); the compositor blurs the rasterised path by it
+ /// (`photocraft_compose::masks::feather_sigma`), as it does a pixel mask's feather.
pub feather: f32,
}
diff --git a/crates/engine/src/export_preset_cmds.rs b/crates/engine/src/export_preset_cmds.rs
index 3d56c2243..7378e703a 100644
--- a/crates/engine/src/export_preset_cmds.rs
+++ b/crates/engine/src/export_preset_cmds.rs
@@ -12,6 +12,33 @@ const MAX_PRESETS: usize = 256;
const MAX_PX: u32 = 300_000;
const FORMATS: [&str; 6] = ["png", "jpg", "webp", "tif", "tga", "ico"];
+/// Export As › Image Size › Resample, in Photoshop's order: the `image.imageSize` method each
+/// choice sends, and its menu label. The first one is the default.
+pub const RESAMPLE: [(&str, &str); 6] = [
+ ("bicubicAutomatic", "Bicubic Automatic"),
+ ("bicubic", "Bicubic"),
+ ("bicubicSmoother", "Bicubic Smoother"),
+ ("bicubicSharper", "Bicubic Sharper"),
+ ("bilinear", "Bilinear"),
+ ("nearest", "Nearest Neighbor"),
+];
+
+/// Photoshop's Export As default: Bicubic Automatic.
+pub const DEFAULT_RESAMPLE: &str = "bicubicAutomatic";
+
+/// `v` when it names one of [`RESAMPLE`]; otherwise an error listing the choices. Export As
+/// never falls back silently: Image Size would quietly use Bicubic for an unknown name.
+pub fn export_resample(v: &str) -> std::result::Result<&'static str, String> {
+ RESAMPLE.iter().map(|(k, _)| *k).find(|k| *k == v).ok_or_else(|| {
+ let names: Vec<&str> = RESAMPLE.iter().map(|(k, _)| *k).collect();
+ format!("resample must be one of {}", names.join(", "))
+ })
+}
+
+fn default_resample() -> String {
+ DEFAULT_RESAMPLE.into()
+}
+
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ExportPresetSettings {
@@ -33,6 +60,9 @@ pub struct ExportPresetSettings {
pub embed_profile: bool,
/// `"auto"`, `"24"` or `"32"`.
pub tga_bits: String,
+ /// One of [`RESAMPLE`]; presets saved before the choice existed load as the default.
+ #[serde(default = "default_resample")]
+ pub resample: String,
}
impl ExportPresetSettings {
@@ -61,6 +91,7 @@ impl ExportPresetSettings {
if !matches!(self.tga_bits.as_str(), "auto" | "24" | "32") {
return Err("tgaBits must be auto, 24 or 32".into());
}
+ export_resample(&self.resample)?;
Ok(())
}
@@ -79,7 +110,8 @@ impl ExportPresetSettings {
"metadata": "none",
"profile": "document",
"embedProfile": true,
- "tgaBits": "auto"
+ "tgaBits": "auto",
+ "resample": DEFAULT_RESAMPLE
});
if let Some(defaults) = defaults.as_object() {
for (k, v) in defaults {
@@ -196,7 +228,7 @@ pub fn specs() -> Vec<CommandSpec> {
label: "Save Export Preset",
menu: &[],
shortcut: None,
- params: r#"{"name":str,"settings":{"format":"png|jpg|webp|tif|tga|ico","quality":1..100,"lossless":bool,"transparency":bool,"scale":1..1000,"width":px,"height":px,"lockAspect":bool,"sizing":"scale|pixels","metadata":"none|exif|all","profile":"document|srgb","embedProfile":bool,"tgaBits":"auto|24|32"}} (a saved name is replaced)"#,
+ params: r#"{"name":str,"settings":{"format":"png|jpg|webp|tif|tga|ico","quality":1..100,"lossless":bool,"transparency":bool,"scale":1..1000,"width":px,"height":px,"lockAspect":bool,"sizing":"scale|pixels","metadata":"none|exif|all","profile":"document|srgb","embedProfile":bool,"tgaBits":"auto|24|32","resample":"bicubicAutomatic|bicubic|bicubicSmoother|bicubicSharper|bilinear|nearest"="bicubicAutomatic"}} (a saved name is replaced)"#,
enabled: always,
run: save,
journal: false,
@@ -232,7 +264,8 @@ mod tests {
"metadata": "exif",
"profile": "srgb",
"embedProfile": false,
- "tgaBits": "24"
+ "tgaBits": "24",
+ "resample": "nearest"
})
}
@@ -255,6 +288,7 @@ mod tests {
assert_eq!(presets[0]["settings"]["width"], 640);
assert_eq!(presets[0]["settings"]["embedProfile"], false);
assert_eq!(presets[0]["settings"]["metadata"], "exif");
+ assert_eq!(presets[0]["settings"]["resample"], "nearest");
let got = restored.execute("file.export.presets.get", json!({"name": "WEB JPEG"})).unwrap();
assert_eq!(got["preset"]["settings"]["profile"], "srgb");
@@ -276,6 +310,9 @@ mod tests {
assert!(s.execute("file.export.presets.save", json!({"name": "x", "settings": {"scale": 0}})).is_err());
assert!(s.execute("file.export.presets.save", json!({"name": "x", "settings": {"metadata": "copyright"}})).is_err());
assert!(s.execute("file.export.presets.save", json!({"name": "x", "settings": {"profile": "fogra39"}})).is_err());
+ let err = s.execute("file.export.presets.save", json!({"name": "x", "settings": {"resample": "lanczos"}})).unwrap_err().to_string();
+ assert!(err.contains("resample must be one of"), "{err}");
+ assert!(s.execute("file.export.presets.save", json!({"name": "x", "settings": {"resample": 3}})).is_err());
assert!(s.execute("file.export.presets.delete", json!({"name": "missing"})).is_err());
assert!(s.execute("file.export.presets.get", json!({"name": ""})).is_err());
@@ -286,5 +323,6 @@ mod tests {
]));
assert_eq!(loaded.len(), 1);
assert_eq!(loaded[0].name, "ok");
+ assert_eq!(loaded[0].settings.resample, DEFAULT_RESAMPLE, "a preset saved before Resample existed loads with the default");
}
}
diff --git a/crates/engine/src/layer_menu_cmds.rs b/crates/engine/src/layer_menu_cmds.rs
index 366f9c8d3..bac385a10 100644
--- a/crates/engine/src/layer_menu_cmds.rs
+++ b/crates/engine/src/layer_menu_cmds.rs
@@ -876,11 +876,16 @@ fn export_layer(s: &mut Session, p: &Value, cmd: &str, png_only: bool) -> Result
return Err(bad(cmd, "Quick Export as PNG writes .png files"));
}
let scale = num(p, "scale", 100.0).clamp(1.0, 1000.0);
+ // Export As › Resample; checked even at 100 % so a typo never goes unnoticed.
+ let resample = match p.get("resample") {
+ None | Some(Value::Null) => crate::export_preset_cmds::DEFAULT_RESAMPLE,
+ Some(v) => crate::export_preset_cmds::export_resample(v.as_str().ok_or_else(|| bad(cmd, "`resample` must be a string"))?).map_err(|e| bad(cmd, e))?,
+ };
if (scale - 100.0).abs() > 1e-3 {
let mut tmp = Session::new();
tmp.add_document(ldoc, None);
let w = (tmp.active().map_or(1, |d| d.doc.size.width) as f32 * scale / 100.0).round().max(1.0);
- tmp.execute("image.imageSize", json!({"width": w}))?;
+ tmp.execute("image.imageSize", json!({"width": w, "resample": resample}))?;
ldoc = (*tmp.active().ok_or(EngineError::NoDocument)?.doc).clone();
}
let out = photocraft_io::export(&ldoc, path, &Default::default()).map_err(|e| other(e.to_string()))?;
@@ -994,7 +999,7 @@ pub fn specs() -> Vec<CommandSpec> {
"layer.exportAs",
"Export As…",
["Layer"],
- r##"{"layer":id?,"path":text,"scale":1..1000=100} (format from the path's extension)"##,
+ r##"{"layer":id?,"path":text,"scale":1..1000=100,"resample":"bicubicAutomatic|bicubic|bicubicSmoother|bicubicSharper|bilinear|nearest"="bicubicAutomatic"} (format from the path's extension; the document is not resampled)"##,
has_layer,
|s, p| export_layer(s, p, "layer.exportAs", false)
),
diff --git a/crates/engine/src/layer_menu_cmds/tests.rs b/crates/engine/src/layer_menu_cmds/tests.rs
index 46688500b..9694564a0 100644
--- a/crates/engine/src/layer_menu_cmds/tests.rs
+++ b/crates/engine/src/layer_menu_cmds/tests.rs
@@ -385,6 +385,38 @@ fn export_layer_trims_to_its_pixels() {
let _ = std::fs::remove_dir_all(&dir);
}
+/// Layer › Export As › Resample: Nearest Neighbor turns each layer pixel into an exact 2 × 2
+/// block at 200 %, an unknown method is an error (never a silent Bicubic), and the document is
+/// left as it was.
+#[test]
+fn export_layer_resamples_with_the_chosen_method() {
+ let dir = std::env::temp_dir().join(format!("pc-layer-export-resample-{}", std::process::id()));
+ std::fs::create_dir_all(&dir).unwrap();
+ for depth in [8, 16] {
+ let mut s = session(depth, "rgb");
+ paint(&mut s, |x, y| if (x + y) % 2 == 0 { [1.0, 0.0, 0.0, 1.0] } else { [0.0, 0.0, 1.0, 1.0] });
+ let before = s.active().unwrap().doc.clone();
+ let path = dir.join(format!("nearest-{depth}.png"));
+ let path = path.to_string_lossy();
+ let r = s.execute("layer.exportAs", json!({"path": path, "scale": 200, "resample": "nearest"})).unwrap();
+ assert_eq!((r["width"].as_u64(), r["height"].as_u64()), (Some(80), Some(60)));
+ let out = photocraft_io::import("x.png", &std::fs::read(&*path).unwrap()).unwrap().document;
+ let surf = out.layers[0].surface().unwrap();
+ for y in 0..60 {
+ for x in 0..80 {
+ let want = if (x / 2 + y / 2) % 2 == 0 { [1.0, 0.0, 0.0, 1.0] } else { [0.0, 0.0, 1.0, 1.0] };
+ assert_eq!(surf.rgba(x, y), want, "{depth}-bit pixel {x},{y}");
+ }
+ }
+ for bad in [json!("lanczos"), json!("Nearest"), json!(""), json!(2)] {
+ let err = s.execute("layer.exportAs", json!({"path": path, "scale": 200, "resample": bad})).unwrap_err().to_string();
+ assert!(err.contains("resample"), "{depth}-bit {bad}: {err}");
+ }
+ assert!(std::sync::Arc::ptr_eq(&s.active().unwrap().doc, &before), "{depth}-bit: exporting never edits the document");
+ }
+ let _ = std::fs::remove_dir_all(&dir);
+}
+
#[test]
fn stack_modes_render_from_the_nested_layers() {
let mut s = session(8, "rgb");
diff --git a/crates/ui-egui/src/export_dialog.rs b/crates/ui-egui/src/export_dialog.rs
index 9367045af..3b9e23238 100644
--- a/crates/ui-egui/src/export_dialog.rs
+++ b/crates/ui-egui/src/export_dialog.rs
@@ -9,6 +9,8 @@ use std::sync::Mutex;
use photocraft_doc::Document;
use serde_json::{Map, Value, json};
+use photocraft_engine::export_preset_cmds::{DEFAULT_RESAMPLE, RESAMPLE, export_resample};
+
use crate::state::DialogKind;
use crate::theme::Tokens;
use crate::{ExportSettings, PhotocraftApp};
@@ -41,6 +43,9 @@ fn seed_remembered(app: &PhotocraftApp, f: &mut Map<String, Value>) {
if let Some(v) = saved.get("metadata").and_then(Value::as_str).filter(|v| ["none", "exif", "all"].contains(v)) {
f.insert("metadata".into(), json!(v));
}
+ if let Some(v) = saved.get("resample").and_then(Value::as_str).filter(|v| export_resample(v).is_ok()) {
+ f.insert("resample".into(), json!(v));
+ }
if let Some(v) = saved.get("tgaBits").and_then(Value::as_str).filter(|v| ["auto", "24", "32"].contains(v)) {
f.insert("tgaBits".into(), json!(v));
}
@@ -65,8 +70,22 @@ fn seed_remembered(app: &PhotocraftApp, f: &mut Map<String, Value>) {
/// Record the settings for the next Export As (see [`seed_remembered`]).
fn remember(app: &mut PhotocraftApp, f: &Map<String, Value>) {
- const KEYS: [&str; 13] =
- ["format", "quality", "lossless", "transparency", "scale", "metadata", "tgaBits", "sizing", "width", "height", "lockAspect", "profile", "embedProfile"];
+ const KEYS: [&str; 14] = [
+ "format",
+ "quality",
+ "lossless",
+ "transparency",
+ "scale",
+ "resample",
+ "metadata",
+ "tgaBits",
+ "sizing",
+ "width",
+ "height",
+ "lockAspect",
+ "profile",
+ "embedProfile",
+ ];
let saved: Map<String, Value> = KEYS.iter().filter_map(|k| f.get(*k).map(|v| ((*k).to_string(), v.clone()))).collect();
app.session.prefs.edit(|p| {
p.dialogs.insert(COMMAND.into(), Value::Object(saved));
@@ -83,6 +102,7 @@ pub fn open(app: &mut PhotocraftApp) -> Result<u64, String> {
f.insert("lossless".into(), json!(app.session.prefs().export.webp_lossless));
f.insert("transparency".into(), json!(true));
f.insert("scale".into(), json!(100));
+ f.insert("resample".into(), json!(DEFAULT_RESAMPLE));
f.insert("metadata".into(), json!("none"));
f.insert("tgaBits".into(), json!("auto"));
f.insert("sizing".into(), json!("scale"));
@@ -240,9 +260,27 @@ fn n(f: &Map<String, Value>, k: &str, d: f64) -> f64 {
f.get(k).and_then(Value::as_f64).unwrap_or(d)
}
-/// The document as exported: scaled (engine Image Size, bicubic) and flattened over white when
-/// transparency is off or the format has no alpha.
+/// Image Size's method for the exported copy (Export As › Resample). A missing choice is
+/// Photoshop's default, Bicubic Automatic; an unknown one is an error, never a silent Bicubic.
+/// The preview proxy (`max_side`) resamples bilinearly to stay fast, except for Nearest
+/// Neighbor, whose hard pixel edges are the point of choosing it and cost nothing extra.
+fn resample_method(f: &Map<String, Value>, max_side: Option<u32>) -> Result<&'static str, String> {
+ let chosen = match f.get("resample") {
+ None | Some(Value::Null) => DEFAULT_RESAMPLE,
+ Some(v) => export_resample(v.as_str().ok_or("resample must be a string")?)?,
+ };
+ Ok(if max_side.is_some() && chosen != "nearest" { "bilinear" } else { chosen })
+}
+
+/// Whether the dialog asks for Nearest Neighbor (the preview then magnifies without smoothing).
+fn nearest(f: &Map<String, Value>) -> bool {
+ f.get("resample").and_then(Value::as_str) == Some("nearest")
+}
+
+/// The document as exported: scaled (engine Image Size, with the dialog's Resample method) and
+/// flattened over white when transparency is off or the format has no alpha.
fn export_document(doc: &Document, f: &Map<String, Value>, max_side: Option<u32>) -> Result<Document, String> {
+ let resample = resample_method(f, max_side)?;
let mut session = photocraft_engine::Session::new();
session.add_document(doc.clone(), None);
if s(f, "profile") == "srgb" && doc.icc_profile.is_some() {
@@ -253,9 +291,7 @@ fn export_document(doc: &Document, f: &Map<String, Value>, max_side: Option<u32>
return Err("ICO export is limited to 256 × 256 pixels; reduce the export scale".into());
}
if (w - doc.size.width as f64).abs() >= 1.0 || (h - doc.size.height as f64).abs() >= 1.0 {
- session
- .execute("image.imageSize", json!({"width": w, "height": h, "resample": if max_side.is_some() { "bilinear" } else { "bicubic" }}))
- .map_err(|e| e.to_string())?;
+ session.execute("image.imageSize", json!({"width": w, "height": h, "resample": resample})).map_err(|e| e.to_string())?;
}
let fmt = s_fmt(f);
if !f.get("transparency").and_then(Value::as_bool).unwrap_or(true) || fmt == "jpg" {
@@ -446,11 +482,17 @@ struct CachedPreview {
texture: Option<Arc<egui::TextureHandle>>,
}
-fn cache_preview(ui: &mut egui::Ui, key: egui::Id, signature: String, result: Result<PreviewPixels, String>) -> CachedPreview {
+/// The preview texture's filter: a small export is magnified to fill the preview, and with
+/// Nearest Neighbor that magnification keeps hard pixel edges too.
+fn preview_filter(f: &Map<String, Value>) -> egui::TextureOptions {
+ if nearest(f) { egui::TextureOptions::NEAREST } else { egui::TextureOptions::LINEAR }
+}
+
+fn cache_preview(ui: &mut egui::Ui, key: egui::Id, signature: String, result: Result<PreviewPixels, String>, filter: egui::TextureOptions) -> CachedPreview {
let preview = match result {
Ok(pixels) => {
let image = egui::ColorImage::from_rgba_unmultiplied([pixels.width, pixels.height], &pixels.rgba);
- let texture = Arc::new(ui.ctx().load_texture("export-preview", image, egui::TextureOptions::LINEAR));
+ let texture = Arc::new(ui.ctx().load_texture("export-preview", image, filter));
CachedPreview { signature, estimate: pixels.estimate, texture: Some(texture) }
}
Err(error) => {
@@ -585,6 +627,32 @@ fn size_fields(ui: &mut egui::Ui, f: &mut Map<String, Value>, src_w: f64, src_h:
}
}
+/// Export As › Image Size › Resample, with Photoshop's choices (only the exported copy is
+/// resampled; the document keeps its pixels).
+fn resample_field(ui: &mut egui::Ui, f: &mut Map<String, Value>) {
+ let t = Tokens::get(ui.ctx());
+ ui.horizontal(|ui| {
+ ui.label(egui::RichText::new(tl!("Resample")).color(t.text_dim));
+ let mut method = resample_method(f, None).unwrap_or(DEFAULT_RESAMPLE).to_string();
+ let opts: Vec<(String, &str)> = RESAMPLE.iter().map(|(k, label)| ((*k).to_string(), resample_label(label))).collect();
+ if crate::widgets::dropdown(ui, "export-resample", &mut method, &opts, 130.0) {
+ f.insert("resample".into(), json!(method));
+ }
+ });
+}
+
+/// The translated label of a [`RESAMPLE`] choice (literal `tl!`s, so the catalogue check sees them).
+fn resample_label(label: &str) -> &'static str {
+ match label {
+ "Bicubic" => tl!("Bicubic"),
+ "Bicubic Smoother" => tl!("Bicubic Smoother"),
+ "Bicubic Sharper" => tl!("Bicubic Sharper"),
+ "Bilinear" => tl!("Bilinear"),
+ "Nearest Neighbor" => tl!("Nearest Neighbor"),
+ _ => tl!("Bicubic Automatic"),
+ }
+}
+
fn apply_preset(f: &mut Map<String, Value>, settings: &photocraft_engine::export_preset_cmds::ExportPresetSettings, src_w: f64, src_h: f64) {
f.insert("format".into(), json!(settings.format));
f.insert("quality".into(), json!(settings.quality));
@@ -597,6 +665,7 @@ fn apply_preset(f: &mut Map<String, Value>, settings: &photocraft_engine::export
f.insert("profile".into(), json!(settings.profile));
f.insert("embedProfile".into(), json!(settings.embed_profile));
f.insert("tgaBits".into(), json!(settings.tga_bits));
+ f.insert("resample".into(), json!(settings.resample));
if settings.sizing == "pixels" {
f.insert("width".into(), json!(settings.width));
f.insert("height".into(), json!(settings.height));
@@ -628,6 +697,7 @@ fn preset_settings(f: &Map<String, Value>) -> Value {
"profile": if s(f, "profile") == "srgb" { "srgb" } else { "document" },
"embedProfile": f.get("embedProfile").and_then(Value::as_bool).unwrap_or(true),
"tgaBits": bits,
+ "resample": resample_method(f, None).unwrap_or(DEFAULT_RESAMPLE),
})
}
@@ -771,6 +841,7 @@ pub fn body(app: &mut PhotocraftApp, ui: &mut egui::Ui, f: &mut Map<String, Valu
ui.label(egui::RichText::new(tl!("Image Size")).font(crate::theme::semibold(12.0)).color(t.text));
let (bw, bh) = (n(f, "__w", f64::from(doc.size.width)), n(f, "__h", f64::from(doc.size.height)));
size_fields(ui, f, bw, bh);
+ resample_field(ui, f);
let (w, h) = (n(f, "width", bw), n(f, "height", bh));
ui.label(egui::RichText::new(format!("{w} × {h} px")).color(t.text_dim).size(11.5));
if fmt == "ico" && (w > 256.0 || h > 256.0) {
@@ -784,7 +855,7 @@ pub fn body(app: &mut PhotocraftApp, ui: &mut egui::Ui, f: &mut Map<String, Valu
let layer = f.get("__layer").and_then(Value::as_u64);
let key = egui::Id::new(("export-preview", doc.id.0, app.session.active().map_or(0, |s| s.revision), layer));
let sig = format!(
- "{}{}{}{}{}{}{}{}{}{}{}{}",
+ "{}{}{}{}{}{}{}{}{}{}{}{}{}",
s_fmt(f),
n(f, "quality", 85.0),
lossless(f),
@@ -796,7 +867,8 @@ pub fn body(app: &mut PhotocraftApp, ui: &mut egui::Ui, f: &mut Map<String, Valu
s(f, "tgaBits"),
s(f, "profile"),
f.get("embedProfile").and_then(Value::as_bool).unwrap_or(true),
- s(f, "sizing")
+ s(f, "sizing"),
+ s(f, "resample")
);
let cached: Option<CachedPreview> = ui.data(|d| d.get_temp(key));
let preview = match cached.filter(|cached| cached.signature == sig) {
@@ -814,7 +886,8 @@ pub fn body(app: &mut PhotocraftApp, ui: &mut egui::Ui, f: &mut Map<String, Valu
let source = source_document(app, f).unwrap_or_else(|_| doc.clone());
Some(preview_sync(app, &source, f))
};
- result.map(|result| cache_preview(ui, key, sig, result))
+ let filter = preview_filter(f);
+ result.map(|result| cache_preview(ui, key, sig, result, filter))
}
};
let side = 300.0;
@@ -1000,6 +1073,114 @@ mod tests {
assert!(saved.get("path").is_none() && saved.get("__w").is_none() && saved.get("__layer").is_none());
}
+ /// A red/blue checkerboard at `depth`, one pixel per square.
+ fn checker_doc(depth: photocraft_doc::SampleType) -> Document {
+ use photocraft_doc::{Color, ColorMode, Size};
+ let mut doc = Document::with_background("checker", Size::new(5, 3), ColorMode::Rgb, depth, Color::WHITE);
+ let b = doc.bounds();
+ let surf = doc.layers[0].surface_mut().unwrap();
+ let fmt = surf.format();
+ let mut data = Vec::new();
+ for y in b.y0..b.y1 {
+ for x in b.x0..b.x1 {
+ data.extend(photocraft_raster::from_rgba(&fmt, checker(x, y)));
+ }
+ }
+ surf.write_region(b, &data);
+ doc
+ }
+
+ fn checker(x: i32, y: i32) -> [f32; 4] {
+ if (x + y) % 2 == 0 { [1.0, 0.0, 0.0, 1.0] } else { [0.0, 0.0, 1.0, 1.0] }
+ }
+
+ /// Export As › Resample › Nearest Neighbor at 200 %: every source pixel becomes an exact
+ /// 2 × 2 block, at 8 and 16 bits, and the document keeps its pixels. Bicubic Automatic (the
+ /// default) blends the squares instead.
+ #[test]
+ fn nearest_neighbor_doubles_each_pixel_into_an_exact_block() {
+ use photocraft_doc::SampleType;
+ for depth in [SampleType::U8, SampleType::U16] {
+ let doc = checker_doc(depth);
+ let before = doc.clone();
+ let mut f = Map::new();
+ f.insert("format".into(), json!("png"));
+ f.insert("scale".into(), json!(200));
+ f.insert("resample".into(), json!("nearest"));
+ let out = export_document(&doc, &f, None).unwrap();
+ assert_eq!((out.size.width, out.size.height), (10, 6));
+ assert_eq!(out.depth, depth);
+ let surf = out.layers[0].surface().unwrap();
+ for y in 0..6 {
+ for x in 0..10 {
+ assert_eq!(surf.rgba(x, y), checker(x / 2, y / 2), "{depth:?} pixel {x},{y}");
+ }
+ }
+ assert_eq!(doc, before, "{depth:?}: export leaves the source document unchanged");
+
+ // The preview proxy keeps Nearest Neighbor's hard edges too.
+ let proxy = export_document(&doc, &f, Some(512)).unwrap();
+ assert_eq!(proxy.layers[0].surface().unwrap().rgba(1, 1), checker(0, 0), "{depth:?}: preview proxy is nearest as well");
+ assert_eq!(preview_filter(&f), egui::TextureOptions::NEAREST);
+
+ f.insert("resample".into(), json!(DEFAULT_RESAMPLE));
+ let smooth = export_document(&doc, &f, None).unwrap();
+ let blended = (0..6).flat_map(|y| (0..10).map(move |x| (x, y))).any(|(x, y)| {
+ let p = smooth.layers[0].surface().unwrap().rgba(x, y);
+ p[0] > 0.01 && p[2] > 0.01
+ });
+ assert!(blended, "{depth:?}: Bicubic Automatic blends neighbouring squares");
+ assert_eq!(preview_filter(&f), egui::TextureOptions::LINEAR);
+ }
+ }
+
+ /// Every Resample choice reaches Image Size; a method Export As does not offer is an error
+ /// naming the choices, never a silent Bicubic, and a missing one is Bicubic Automatic.
+ #[test]
+ fn resample_choices_are_checked() {
+ let doc = checker_doc(photocraft_doc::SampleType::U8);
+ let mut f = Map::new();
+ f.insert("scale".into(), json!(300));
+ for (method, _) in RESAMPLE {
+ f.insert("resample".into(), json!(method));
+ let out = export_document(&doc, &f, None).unwrap();
+ assert_eq!((out.size.width, out.size.height), (15, 9), "{method}");
+ }
+ for bad in [json!("lanczos"), json!("NEAREST"), json!(""), json!(1), json!({"m": "nearest"})] {
+ f.insert("resample".into(), bad.clone());
+ let err = export_document(&doc, &f, None).unwrap_err();
+ assert!(err.contains("resample must be"), "{bad}: {err}");
+ assert!(export_document(&doc, &f, Some(512)).is_err(), "{bad}: the preview reports it too");
+ }
+ f.remove("resample");
+ assert_eq!(resample_method(&f, None).unwrap(), "bicubicAutomatic");
+ assert_eq!(resample_method(&f, Some(512)).unwrap(), "bilinear", "the preview stays on the fast path");
+ }
+
+ /// Resample is remembered with the other settings; a saved value the menu does not offer
+ /// opens the dialog with the default.
+ #[test]
+ fn resample_is_remembered_and_a_bad_saved_value_falls_back() {
+ let mut app = PhotocraftApp::new(photocraft_engine::Session::new(), crate::Services::default());
+ app.run("file.new", json!({"width": 20, "height": 10})).unwrap();
+ let id = open(&mut app).unwrap();
+ assert_eq!(app.ui.dialog_mut(id).unwrap().fields["resample"], DEFAULT_RESAMPLE, "Photoshop's default");
+ let mut f = app.ui.dialog_mut(id).unwrap().fields.clone();
+ f.insert("resample".into(), json!("nearest"));
+ remember(&mut app, &f);
+ assert_eq!(app.session.prefs().dialogs[COMMAND]["resample"], "nearest");
+ let id = open(&mut app).unwrap();
+ assert_eq!(app.ui.dialog_mut(id).unwrap().fields["resample"], "nearest");
+
+ for bad in [json!("lanczos"), json!(7), json!(null)] {
+ app.session.prefs.edit(|p| {
+ p.dialogs.insert(COMMAND.into(), json!({"resample": bad}));
+ });
+ let id = open(&mut app).unwrap();
+ assert_eq!(app.ui.dialog_mut(id).unwrap().fields["resample"], DEFAULT_RESAMPLE, "saved {bad}");
+ }
+ }
+
#[test]
fn export_document_scales_height_when_rounded_width_is_unchanged() {
use photocraft_doc::{Color, ColorMode, SampleType, Size};
@@ -1297,9 +1478,12 @@ mod tests {
profile: "document".into(),
embed_profile: false,
tga_bits: "auto".into(),
+ resample: "nearest".into(),
};
let mut f = Map::new();
apply_preset(&mut f, &pixels, 400.0, 200.0);
+ assert_eq!(f.get("resample"), Some(&json!("nearest")), "a preset restores its Resample method");
+ assert_eq!(preset_settings(&f)["resample"], "nearest", "and saves it");
assert_eq!(f.get("width"), Some(&json!(64)));
assert_eq!(f.get("height"), Some(&json!(32)));
assert_eq!(f.get("sizing"), Some(&json!("pixels")));
diff --git a/crates/ui-egui/src/i18n/cs.tsv b/crates/ui-egui/src/i18n/cs.tsv
index 5cfc0f8ff..93c789625 100644
--- a/crates/ui-egui/src/i18n/cs.tsv
+++ b/crates/ui-egui/src/i18n/cs.tsv
@@ -3783,3 +3783,6 @@ navigator Zoom Zvětšení
# View › Guides › right-click a guide
Edit Selected Guides Upravit vybraná vodítka
Clear Selected Guides Vymazat vybraná vodítka
+ Bicubic Automatic Bikubická automatická
+ Bicubic Smoother Bikubická hladší
+ Bicubic Sharper Bikubická ostřejší
diff --git a/crates/ui-egui/src/i18n/de.tsv b/crates/ui-egui/src/i18n/de.tsv
index 05ac77803..5d70deff3 100644
--- a/crates/ui-egui/src/i18n/de.tsv
+++ b/crates/ui-egui/src/i18n/de.tsv
@@ -3177,3 +3177,6 @@ curves Smooth Glätten
# View › Guides › right-click a guide
Edit Selected Guides Ausgewählte Hilfslinien bearbeiten
Clear Selected Guides Ausgewählte Hilfslinien löschen
+ Bicubic Automatic Bikubisch automatisch
+ Bicubic Smoother Bikubisch glatter
+ Bicubic Sharper Bikubisch schärfer
diff --git a/crates/ui-egui/src/i18n/el.tsv b/crates/ui-egui/src/i18n/el.tsv
index c6c5ff8f6..d4330e7cb 100644
--- a/crates/ui-egui/src/i18n/el.tsv
+++ b/crates/ui-egui/src/i18n/el.tsv
@@ -3875,3 +3875,6 @@ curves Smooth Εξομάλυνση
# View › Guides › right-click a guide
Edit Selected Guides Επεξεργασία επιλεγμένων οδηγών
Clear Selected Guides Απαλοιφή επιλεγμένων οδηγών
+ Bicubic Automatic Δικυβική αυτόματη
+ Bicubic Smoother Δικυβική πιο ομαλή
+ Bicubic Sharper Δικυβική πιο ευκρινής
diff --git a/crates/ui-egui/src/i18n/es.tsv b/crates/ui-egui/src/i18n/es.tsv
index e24171195..cc8f1287f 100644
--- a/crates/ui-egui/src/i18n/es.tsv
+++ b/crates/ui-egui/src/i18n/es.tsv
@@ -4137,3 +4137,6 @@ navigator Zoom Zoom
# View › Guides › right-click a guide
Edit Selected Guides Editar guías seleccionadas
Clear Selected Guides Borrar guías seleccionadas
+ Bicubic Automatic Bicúbica automática
+ Bicubic Smoother Bicúbica más suavizada
+ Bicubic Sharper Bicúbica más enfocada
diff --git a/crates/ui-egui/src/i18n/fr.tsv b/crates/ui-egui/src/i18n/fr.tsv
index db40d97ab..1d5022093 100644
--- a/crates/ui-egui/src/i18n/fr.tsv
+++ b/crates/ui-egui/src/i18n/fr.tsv
@@ -3179,3 +3179,6 @@ curves Smooth Lisser
# View › Guides › right-click a guide
Edit Selected Guides Modifier les repères sélectionnés
Clear Selected Guides Effacer les repères sélectionnés
+ Bicubic Automatic Bicubique automatique
+ Bicubic Smoother Bicubique plus lisse
+ Bicubic Sharper Bicubique plus net
diff --git a/crates/ui-egui/src/i18n/hu.tsv b/crates/ui-egui/src/i18n/hu.tsv
index 0404b429c..d61e2a5a8 100644
--- a/crates/ui-egui/src/i18n/hu.tsv
+++ b/crates/ui-egui/src/i18n/hu.tsv
@@ -4094,3 +4094,6 @@ cameraRaw Yellow Sárga
# View › Guides › right-click a guide
Edit Selected Guides Kijelölt segédvonalak szerkesztése
Clear Selected Guides Kijelölt segédvonalak törlése
+ Bicubic Automatic Automatikus bikubikus
+ Bicubic Smoother Simább bikubikus
+ Bicubic Sharper Élesebb bikubikus
diff --git a/crates/ui-egui/src/i18n/id.tsv b/crates/ui-egui/src/i18n/id.tsv
index 544ead05a..ddd5b1c6c 100644
--- a/crates/ui-egui/src/i18n/id.tsv
+++ b/crates/ui-egui/src/i18n/id.tsv
@@ -3166,3 +3166,6 @@ curves Smooth Haluskan
# View › Guides › right-click a guide
Edit Selected Guides Edit Panduan Terpilih
Clear Selected Guides Hapus Panduan Terpilih
+ Bicubic Automatic Bicubic otomatis
+ Bicubic Smoother Bicubic lebih halus
+ Bicubic Sharper Bicubic lebih tajam
diff --git a/crates/ui-egui/src/i18n/it.tsv b/crates/ui-egui/src/i18n/it.tsv
index 40b468926..ebdb71f12 100644
--- a/crates/ui-egui/src/i18n/it.tsv
+++ b/crates/ui-egui/src/i18n/it.tsv
@@ -4296,3 +4296,6 @@ shape Appearance Aspetto
# View › Guides › right-click a guide
Edit Selected Guides Modifica guide selezionate
Clear Selected Guides Cancella guide selezionate
+ Bicubic Automatic Bicubica automatica
+ Bicubic Smoother Bicubica più morbida
+ Bicubic Sharper Bicubica più nitida
diff --git a/crates/ui-egui/src/i18n/ja.tsv b/crates/ui-egui/src/i18n/ja.tsv
index 1d64bf868..4f9f4cc09 100644
--- a/crates/ui-egui/src/i18n/ja.tsv
+++ b/crates/ui-egui/src/i18n/ja.tsv
@@ -3851,3 +3851,6 @@ curves Smooth スムーズ
# View › Guides › right-click a guide
Edit Selected Guides 選択したガイドを編集
Clear Selected Guides 選択したガイドを消去
+ Bicubic Automatic バイキュービック法 (自動)
+ Bicubic Smoother バイキュービック法 - 滑らか
+ Bicubic Sharper バイキュービック法 - シャープ
diff --git a/crates/ui-egui/src/i18n/ko.tsv b/crates/ui-egui/src/i18n/ko.tsv
index e76a3c982..327b73b41 100644
--- a/crates/ui-egui/src/i18n/ko.tsv
+++ b/crates/ui-egui/src/i18n/ko.tsv
@@ -3353,3 +3353,6 @@ curves Smooth 매끄럽게
# View › Guides › right-click a guide
Edit Selected Guides 선택한 안내선 편집
Clear Selected Guides 선택한 안내선 지우기
+ Bicubic Automatic 쌍입방 자동
+ Bicubic Smoother 쌍입방 더 부드럽게
+ Bicubic Sharper 쌍입방 더 선명하게
diff --git a/crates/ui-egui/src/i18n/nl.tsv b/crates/ui-egui/src/i18n/nl.tsv
index 2c9416c70..705f1e525 100644
--- a/crates/ui-egui/src/i18n/nl.tsv
+++ b/crates/ui-egui/src/i18n/nl.tsv
@@ -3935,3 +3935,6 @@ curves Smooth Vloeiend maken
# View › Guides › right-click a guide
Edit Selected Guides Geselecteerde hulplijnen bewerken
Clear Selected Guides Geselecteerde hulplijnen wissen
+ Bicubic Automatic Bicubisch automatisch
+ Bicubic Smoother Bicubisch vloeiender
+ Bicubic Sharper Bicubisch scherper
diff --git a/crates/ui-egui/src/i18n/pl.tsv b/crates/ui-egui/src/i18n/pl.tsv
index eee1e61a9..61f1aeb59 100644
--- a/crates/ui-egui/src/i18n/pl.tsv
+++ b/crates/ui-egui/src/i18n/pl.tsv
@@ -3773,3 +3773,6 @@ curves Smooth Wygładź
# View › Guides › right-click a guide
Edit Selected Guides Edytuj zaznaczone prowadnice
Clear Selected Guides Usuń zaznaczone prowadnice
+ Bicubic Automatic Dwusześcienna automatyczna
+ Bicubic Smoother Dwusześcienna wygładzona
+ Bicubic Sharper Dwusześcienna wyostrzona
diff --git a/crates/ui-egui/src/i18n/pt-br.tsv b/crates/ui-egui/src/i18n/pt-br.tsv
index 3e10fe7db..7c29aeffd 100644
--- a/crates/ui-egui/src/i18n/pt-br.tsv
+++ b/crates/ui-egui/src/i18n/pt-br.tsv
@@ -3965,3 +3965,6 @@ layerLabel No Color Sem cor
# View › Guides › right-click a guide
Edit Selected Guides Editar guias selecionadas
Clear Selected Guides Limpar guias selecionadas
+ Bicubic Automatic Bicúbica automática
+ Bicubic Smoother Bicúbica mais suave
+ Bicubic Sharper Bicúbica mais nítida
diff --git a/crates/ui-egui/src/i18n/ru.tsv b/crates/ui-egui/src/i18n/ru.tsv
index 862788630..81317e6be 100644
--- a/crates/ui-egui/src/i18n/ru.tsv
+++ b/crates/ui-egui/src/i18n/ru.tsv
@@ -3144,3 +3144,6 @@ curves Smooth Сгладить
# View › Guides › right-click a guide
Edit Selected Guides Изменить выбранные направляющие
Clear Selected Guides Удалить выбранные направляющие
+ Bicubic Automatic Бикубическая, автоматически
+ Bicubic Smoother Бикубическая, глаже
+ Bicubic Sharper Бикубическая, чётче
diff --git a/crates/ui-egui/src/i18n/sr.tsv b/crates/ui-egui/src/i18n/sr.tsv
index b91b67b3e..a4447f475 100644
--- a/crates/ui-egui/src/i18n/sr.tsv
+++ b/crates/ui-egui/src/i18n/sr.tsv
@@ -4248,3 +4248,6 @@ shape Appearance Izgled
# View › Guides › right-click a guide
Edit Selected Guides Uredi izabrane vodilje
Clear Selected Guides Ukloni izabrane vodilje
+ Bicubic Automatic Bikubično automatski
+ Bicubic Smoother Bikubično glađe
+ Bicubic Sharper Bikubično oštrije
diff --git a/crates/ui-egui/src/i18n/tr.tsv b/crates/ui-egui/src/i18n/tr.tsv
index 4c8f06ccc..c19ceb1f1 100644
--- a/crates/ui-egui/src/i18n/tr.tsv
+++ b/crates/ui-egui/src/i18n/tr.tsv
@@ -3905,3 +3905,6 @@ cameraData Lens Lens
# View › Guides › right-click a guide
Edit Selected Guides Seçili Kılavuzları Düzenle
Clear Selected Guides Seçili Kılavuzları Temizle
+ Bicubic Automatic Bikübik Otomatik
+ Bicubic Smoother Bikübik Pürüzsüzleştirici
+ Bicubic Sharper Bikübik Daha Keskin
diff --git a/crates/ui-egui/src/i18n/uk.tsv b/crates/ui-egui/src/i18n/uk.tsv
index 39597c15c..c77b143b7 100644
--- a/crates/ui-egui/src/i18n/uk.tsv
+++ b/crates/ui-egui/src/i18n/uk.tsv
@@ -3874,3 +3874,6 @@ curves Smooth Згладити
# View › Guides › right-click a guide
Edit Selected Guides Редагувати вибрані напрямні
Clear Selected Guides Очистити вибрані напрямні
+ Bicubic Automatic Бікубічна, автоматично
+ Bicubic Smoother Бікубічна, гладкіша
+ Bicubic Sharper Бікубічна, чіткіша
diff --git a/crates/ui-egui/src/i18n/vi.tsv b/crates/ui-egui/src/i18n/vi.tsv
index ac7123d85..57f9082e9 100644
--- a/crates/ui-egui/src/i18n/vi.tsv
+++ b/crates/ui-egui/src/i18n/vi.tsv
@@ -3661,3 +3661,6 @@ curves Smooth Làm mượt
# View › Guides › right-click a guide
Edit Selected Guides Sửa đường căn đã chọn
Clear Selected Guides Xóa đường căn đã chọn
+ Bicubic Automatic Bicubic tự động
+ Bicubic Smoother Bicubic mượt hơn
+ Bicubic Sharper Bicubic sắc hơn
diff --git a/crates/ui-egui/src/i18n/zh-hans.tsv b/crates/ui-egui/src/i18n/zh-hans.tsv
index 2307739ed..7eaff68ff 100644
--- a/crates/ui-egui/src/i18n/zh-hans.tsv
+++ b/crates/ui-egui/src/i18n/zh-hans.tsv
@@ -2790,3 +2790,6 @@ curves Smooth 平滑
# View › Guides › right-click a guide
Edit Selected Guides 编辑所选参考线
Clear Selected Guides 清除所选参考线
+ Bicubic Automatic 双三次(自动)
+ Bicubic Smoother 双三次(较平滑)
+ Bicubic Sharper 双三次(较锐利)
diff --git a/crates/ui-egui/src/i18n/zh-hant.tsv b/crates/ui-egui/src/i18n/zh-hant.tsv
index 478489f8c..a5eb751ad 100644
--- a/crates/ui-egui/src/i18n/zh-hant.tsv
+++ b/crates/ui-egui/src/i18n/zh-hant.tsv
@@ -2775,3 +2775,6 @@ curves Smooth 平滑
# View › Guides › right-click a guide
Edit Selected Guides 編輯所選參考線
Clear Selected Guides 清除所選參考線
+ Bicubic Automatic 雙三次 (自動)
+ Bicubic Smoother 雙三次 (較平滑)
+ Bicubic Sharper 雙三次 (較銳利)
diff --git a/crates/ui-egui/tests/export_as_scaling.rs b/crates/ui-egui/tests/export_as_scaling.rs
index f1c9cba32..c984f1144 100644
--- a/crates/ui-egui/tests/export_as_scaling.rs
+++ b/crates/ui-egui/tests/export_as_scaling.rs
@@ -129,3 +129,82 @@ fn export_as_scales_a_narrow_image_without_editing_the_source() {
assert_eq!(st.revision, revision, "export must not change source revision");
}
}
+
+/// #5838: Export As › Image Size › Resample. Choose Nearest Neighbor in the real dropdown, export
+/// at 200 %, and every source pixel arrives as an exact 2 × 2 block; the choice is remembered.
+#[test]
+fn export_as_resample_menu_writes_nearest_neighbor_blocks() {
+ let _gpu = photocraft_testkit::gpu_lock();
+ let Some((mut h, writes)) = harness() else { return };
+ h.run_steps(4);
+ {
+ let app = h.state_mut();
+ app.run("file.new", json!({"width": 4, "height": 3, "depth": 8, "background": "white"})).expect("new document");
+ app.session
+ .edit("checker", |doc, active| {
+ let b = doc.bounds();
+ let layer = (*active).ok_or(photocraft_engine::EngineError::NoDocument)?;
+ let surf = doc.layer_mut(layer).and_then(|l| l.surface_mut()).ok_or(photocraft_engine::EngineError::NoDocument)?;
+ let fmt = surf.format();
+ let mut data = Vec::new();
+ for y in b.y0..b.y1 {
+ for x in b.x0..b.x1 {
+ data.extend(photocraft_raster::from_rgba(&fmt, if (x + y) % 2 == 0 { [1.0, 0.0, 0.0, 1.0] } else { [0.0, 0.0, 1.0, 1.0] }));
+ }
+ }
+ surf.write_region(b, &data);
+ Ok(())
+ })
+ .expect("paint a checkerboard");
+ app.sync_views();
+ }
+ let source = h.state().session.active().expect("document").doc.clone();
+ let ctx = h.ctx.clone();
+ menus::invoke(h.state_mut(), &ctx, "file.export.exportAs", json!({})).expect("open Export As");
+ h.run_steps(6);
+
+ let label = h.get_by_label("Resample").rect();
+ h.query_all_by_role(egui::accesskit::Role::ComboBox)
+ .find(|n| {
+ let r = n.rect();
+ r.left() >= label.right() && (r.center().y - label.center().y).abs() < 3.0
+ })
+ .expect("Resample dropdown beside its label")
+ .click();
+ h.run_steps(3);
+ h.get_by_label("Nearest Neighbor").click();
+ h.run_steps(3);
+
+ let label = h.get_by_label("Scale").rect();
+ h.query_all_by_role(egui::accesskit::Role::SpinButton)
+ .find(|n| {
+ let r = n.rect();
+ r.left() >= label.right() && r.left() < label.right() + 100.0 && (r.center().y - label.center().y).abs() < 3.0
+ })
+ .expect("Scale numeric field")
+ .click();
+ h.run_steps(2);
+ h.event(egui::Event::Text("200".into()));
+ h.run_steps(3);
+ h.get_by_label("Image Size").click();
+ h.run_steps(3);
+ assert!(h.query_by_label("8 × 6 px").is_some(), "dialog shows the requested output size");
+ evidence(&mut h, 8, "resample-dialog");
+
+ h.get_by_label("Export").click();
+ h.run_steps(6);
+ let written = writes.borrow();
+ assert_eq!(written.len(), 1, "Export writes one file");
+ let png = photocraft_io::import("out.png", &written[0].1).expect("decode the written PNG").document;
+ assert_eq!((png.size.width, png.size.height), (8, 6));
+ let surf = png.layers[0].surface().expect("pixels");
+ for y in 0..6 {
+ for x in 0..8 {
+ let want = if (x / 2 + y / 2) % 2 == 0 { [1.0, 0.0, 0.0, 1.0] } else { [0.0, 0.0, 1.0, 1.0] };
+ assert_eq!(surf.rgba(x, y), want, "pixel {x},{y}");
+ }
+ }
+ let st = h.state().session.active().expect("source remains open");
+ assert!(Arc::ptr_eq(&st.doc, &source), "the source document is unchanged");
+ assert_eq!(h.state().session.prefs().dialogs["file.export.exportAs"]["resample"], "nearest", "the choice is remembered");
+}
diff --git a/docs/scorecard.md b/docs/scorecard.md
index fe9c144ba..5b0a01660 100644
--- a/docs/scorecard.md
+++ b/docs/scorecard.md
@@ -7,7 +7,7 @@ Generated by `cargo xtask scorecard` from `perf/budgets.toml`, `perf/baseline.js
| Area | Done | Partial | Missing | Key numbers |
|---|---:|---:|---:|---|
| [Performance](#performance) | 3 | 22 | 22 | 56 scenarios: 3 within budget, 22 over budget or failing, 9 tracked only, 17 not run, 5 not measurable yet (baseline 2026-10-05) |
-| [File compatibility](#file-compatibility) | 7 | 13 | 7 | io corpus: oracle ≥ 148/170, round trip ≥ 169/170; psd-tools corpus: oracle ≥ 249/309, round trip ≥ 308/309; photoshop oracles: oracle ≥ 185/256, round trip ≥ 258/256 |
+| [File compatibility](#file-compatibility) | 8 | 12 | 7 | io corpus: oracle ≥ 148/170, round trip ≥ 169/170; psd-tools corpus: oracle ≥ 249/309, round trip ≥ 308/309; photoshop oracles: oracle ≥ 185/256, round trip ≥ 258/256 |
| [Tools](#tools) | 33 | 11 | 0 | |
| [Workspace and UI](#workspace-and-ui) | 13 | 6 | 4 | settings that do nothing: 26 of 164 (target 0) |
| [Type](#type) | 4 | 3 | 2 | |
@@ -115,7 +115,7 @@ Corpus floors (`crates/io/tests/corpus.rs`): the enforced minimums; the corpus t
| FILE-215-15 | Layer Style contour picker, curve editor, presets, .shc import/export | partial | [#2912](https://github.com/storytold/photocraft/issues/2912) | Layer Style dialog: contour thumbnail + preset picker (12 standard shapes, own control points) and Anti-aliased on Drop/Inner Shadow, Outer/Inner Glow, Satin, Bevel Gloss Contour and Contour element; Contour Editor (add/drag/delete, Corner, Input/Output, Preset, Load…/Save… .shc per Adobe's public spec, psd shc.rs); corner points render (compose contour_curve_lut) and map to PSD Cnty. Missing: a user contour library (New…, picker Load/Save/Replace Contours), Anti-aliased doesn't change the render yet, .shc not yet checked against a Photoshop-written file |
| FILE-215-16 | Advanced Blending (knockout, blend as group, mask hides effects) end to end | partial | [#215](https://github.com/storytold/photocraft/issues/215) | doc advanced.rs + .pcraft + PSD/layered TIFF (knko infx clbl tsly lmgm vmgm), CPU compose advanced.rs (GPU falls back), blendingOptions command + dialog; 7 psd-tools knockout oracles now pass; knockout-isolated-groups (0.45 % AA edges), advanced-blending, blend-and-clipping still differ |
| FILE-215-17 | CMYK/RGB documents preview spot inks; spot plates export (TIFF extra samples, PDF) | missing | [#215](https://github.com/storytold/photocraft/issues/215) | compose multichannel.rs:1 spot preview for Multichannel only |
-| FILE-215-18 | Save for Web per-slice settings remembered; Export As remembers and offers nearest scaling | partial | [#215](https://github.com/storytold/photocraft/issues/215) | Save for Web settings survive a restart through the remembered dialog settings in prefs.dialogs (web_cmds::remember_web_settings stores them on a complete export, never the destination; file_ui.rs open_web seeds from the session's last export, else the preferences). export_dialog seeds Export As the same way (seed_remembered: format, quality, transparency, scale, metadata, TGA bits) and confirm remembers them as used. Missing: Export As nearest-neighbour scaling |
+| FILE-215-18 | Save for Web per-slice settings remembered; Export As remembers and offers nearest scaling | done | [#215](https://github.com/storytold/photocraft/issues/215) | Save for Web settings survive a restart through the remembered dialog settings in prefs.dialogs (web_cmds::remember_web_settings stores them on a complete export, never the destination; file_ui.rs open_web seeds from the session's last export, else the preferences). export_dialog seeds Export As the same way (seed_remembered: format, quality, transparency, scale, resample, metadata, TGA bits) and confirm remembers them as used. Export As › Image Size › Resample offers Photoshop's six methods (Bicubic Automatic default, Nearest Neighbor included; export_preset_cmds::RESAMPLE, unknown values are errors) for the exported copy only; also layer.exportAs `resample` and export presets (#5838). Tests: export_dialog nearest_neighbor_doubles_each_pixel_into_an_exact_block (8/16-bit), resample_choices_are_checked, resample_is_remembered_and_a_bad_saved_value_falls_back; layer_menu_cmds export_layer_resamples_with_the_chosen_method; tests/export_as_scaling.rs export_as_resample_menu_writes_nearest_neighbor_blocks |
| FILE-215-19 | Save As JPEG opens a JPEG Options dialog (quality 0-12, format options) | missing | [#215](https://github.com/storytold/photocraft/issues/215) | ExportSettings has jpeg_quality 1-100 only (lib.rs:118) |
| FILE-215-20 | Artboard tool with handles and + buttons, Duplicate Artboard beside, vector PDF pages | partial | [#215](https://github.com/storytold/photocraft/issues/215) | artboard_tool.rs: Artboard tool draws, selects, moves and resizes boards by their handles (⇧ keeps proportions), its + buttons add a board or (⌥) a copy beside the selected one (#3033); Duplicate Artboard places the copy beside (#1584); raster PDF pages only |
| FILE-215-21 | Local libraries of colours, patterns, images and layers, as linked items or copies | missing | [#215](https://github.com/storytold/photocraft/issues/215) | Only preset libraries (preset_store.rs) |
diff --git a/scorecard/file_compat.toml b/scorecard/file_compat.toml
index 40b242ea5..c6fd2fe75 100644
--- a/scorecard/file_compat.toml
+++ b/scorecard/file_compat.toml
@@ -127,9 +127,9 @@ note = "compose multichannel.rs:1 spot preview for Multichannel only"
[[item]]
id = "FILE-215-18"
target = "Save for Web per-slice settings remembered; Export As remembers and offers nearest scaling"
-status = "partial"
+status = "done"
issue = 215
-note = "Save for Web settings survive a restart through the remembered dialog settings in prefs.dialogs (web_cmds::remember_web_settings stores them on a complete export, never the destination; file_ui.rs open_web seeds from the session's last export, else the preferences). export_dialog seeds Export As the same way (seed_remembered: format, quality, transparency, scale, metadata, TGA bits) and confirm remembers them as used. Missing: Export As nearest-neighbour scaling"
+note = "Save for Web settings survive a restart through the remembered dialog settings in prefs.dialogs (web_cmds::remember_web_settings stores them on a complete export, never the destination; file_ui.rs open_web seeds from the session's last export, else the preferences). export_dialog seeds Export As the same way (seed_remembered: format, quality, transparency, scale, resample, metadata, TGA bits) and confirm remembers them as used. Export As › Image Size › Resample offers Photoshop's six methods (Bicubic Automatic default, Nearest Neighbor included; export_preset_cmds::RESAMPLE, unknown values are errors) for the exported copy only; also layer.exportAs `resample` and export presets (#5838). Tests: export_dialog nearest_neighbor_doubles_each_pixel_into_an_exact_block (8/16-bit), resample_choices_are_checked, resample_is_remembered_and_a_bad_saved_value_falls_back; layer_menu_cmds export_layer_resamples_with_the_chosen_method; tests/export_as_scaling.rs export_as_resample_menu_writes_nearest_neighbor_blocks"
[[item]]
id = "FILE-215-19"