Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions crates/engine/src/contact_sheet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,8 @@ impl Prepared {
size: 0.5,
opacity: 1.0,
anchor: Anchor::Center,
inset: 0.0,
inset_x: 0.0,
inset_y: 0.0,
color: [32; 3],
shadow: false,
..Default::default()
Expand Down Expand Up @@ -305,7 +306,8 @@ mod tests {
size: 0.5,
opacity: 1.0,
anchor: Anchor::Center,
inset: 0.0,
inset_x: 0.0,
inset_y: 0.0,
color: [32; 3],
shadow: false,
..Default::default()
Expand All @@ -320,7 +322,8 @@ mod tests {
size: 0.5,
opacity: 1.0,
anchor: Anchor::Center,
inset: 0.0,
inset_x: 0.0,
inset_y: 0.0,
color: [32; 3],
shadow: false,
..Default::default()
Expand Down
237 changes: 202 additions & 35 deletions crates/engine/src/export.rs

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion crates/mcp/src/headless.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ impl Backend for Headless {
"engine.commands" => {
let mut v: Vec<Value> = self.session.commands().into_iter().map(|c| serde_json::to_value(c).unwrap_or_default()).collect();
v.push(json!({"id": "app.export", "label": "Export Now", "menu": [], "shortcut": null,
"params": "{path?: output file (.jpg/.png/.tif/.webp/.avif/.dng) | dir?, ids?, preset?, format?: jpeg|png|tiff|webp|avif|dng|original, longEdge?|shortEdge?|width?|height?|megapixels?|percent? (default longEdge 3000; longEdge 0 = full size), dontEnlarge?, ppi?, quality?: 1..100, limitKb?, colorSpace?: srgb|displayP3|adobeRgb|proPhoto|rec2020, bitDepth?: 8|10|16|32, hdr? (HDR output for HDR edits: gain map JPEG, float TIFF), sharpen?: none|screen|matte|glossy, sharpenAmount?: low|standard|high, metadata?: all|allExceptCamera|copyright|none, removeLocation?, naming?, startNumber?, subfolder?, conflict?: unique|overwrite|skip, tiffCompression?: none|lzw|zip, dngCompression?: lossless|deflate|uncompressed, watermark?: text | {text?, vertical? (upright columns, right to left), size? (text height, 0.005..0.5 of the short edge; default 0.035), opacity? (0..1; 0.7), anchor?: topLeft|top|topRight|left|center|right|bottomLeft|bottom|bottomRight, inset? (margin, 0..0.4 of the short edge; 0.025), color? [r,g,b] sRGB, shadow?, image? (graphic drawn instead of the text), imageWidth? (0.01..1 of the photo's width; 0.2)}} — an unknown parameter, an out-of-range watermark size or a value of the wrong kind is an error, not a default",
"params": "{path?: output file (.jpg/.png/.tif/.webp/.avif/.dng) | dir?, ids?, preset?, format?: jpeg|png|tiff|webp|avif|dng|original, longEdge?|shortEdge?|width?|height?|megapixels?|percent? (default longEdge 3000; longEdge 0 = full size), dontEnlarge?, ppi?, quality?: 1..100, limitKb?, colorSpace?: srgb|displayP3|adobeRgb|proPhoto|rec2020, bitDepth?: 8|10|16|32, hdr? (HDR output for HDR edits: gain map JPEG, float TIFF), sharpen?: none|screen|matte|glossy, sharpenAmount?: low|standard|high, metadata?: all|allExceptCamera|copyright|none, removeLocation?, naming?, startNumber?, subfolder?, conflict?: unique|overwrite|skip, tiffCompression?: none|lzw|zip, dngCompression?: lossless|deflate|uncompressed, watermark?: text | {text?, vertical? (upright columns, right to left), size? (text height, 0.005..0.5 of the short edge; default 0.035), opacity? (0..1; 0.7), anchor?: topLeft|top|topRight|left|center|right|bottomLeft|bottom|bottomRight, insetX? (margin from the left/right edge, 0..0.4 of the short edge; 0.025), insetY? (from the top/bottom edge; 0.025), inset? (sets both), rotation?: 0|90|180|270 (degrees clockwise; 0), color? [r,g,b] sRGB, shadow?, image? (graphic drawn instead of the text), imageWidth? (0.01..1 of the photo's width; 0.2)}} — an unknown parameter, an out-of-range watermark size or a value of the wrong kind is an error, not a default",
"enabled": self.session.active().is_some()}));
Ok(Value::Array(v))
}
Expand Down
2 changes: 1 addition & 1 deletion crates/mcp/src/tools.rs
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ pub fn helper_tools(has_ui: bool) -> Vec<Value> {
"colorSpace": {"type": "string", "enum": ["srgb", "displayP3", "adobeRgb", "proPhoto", "rec2020"], "description": "Output colour space (default sRGB; AVIF is always sRGB). adobeRgb = Adobe RGB (1998) compatible; the embedded ICC profile is generated from the published primaries"},
"bitDepth": {"type": "integer", "enum": [8, 10, 16, 32], "description": "Bits per channel: PNG 8|16 (default 8), TIFF 8|16|32 (default 16; 32 = linear float with a linear profile), AVIF 8|10; JPEG/WebP are 8-bit"},
"hdr": {"type": "boolean", "description": "HDR output for photos edited in HDR (develop.hdr): JPEG as an ISO 21496-1 gain map JPEG, AVIF as 10-bit Rec. 2020 PQ, 32-bit TIFF with highlights above 1; other formats and SDR edits export as usual"},
"watermark": {"description": "Text, or {text, vertical (boolean; defaults to false: upright columns right to left), size (text height as a fraction of the short edge, 0.005..0.5; default 0.035), opacity (0..1; default 0.7), anchor (topLeft|top|topRight|left|center|right|bottomLeft|bottom|bottomRight), inset (margin as a fraction of the short edge, 0..0.4; default 0.025), color [r,g,b] (sRGB 0..255), shadow (boolean), image (path of a graphic drawn instead of the text), imageWidth (fraction of the photo's width, 0.01..1; default 0.2)}. Unknown keys and out-of-range sizes are errors"}
"watermark": {"description": "Text, or {text, vertical (boolean; defaults to false: upright columns right to left), size (text height as a fraction of the short edge, 0.005..0.5; default 0.035), opacity (0..1; default 0.7), anchor (topLeft|top|topRight|left|center|right|bottomLeft|bottom|bottomRight), insetX (margin from the left or right edge as a fraction of the short edge, 0..0.4; default 0.025), insetY (margin from the top or bottom edge, same units), inset (sets both), rotation (degrees clockwise: 0|90|180|270; default 0; the watermark is sized before it is turned), color [r,g,b] (sRGB 0..255), shadow (boolean), image (path of a graphic drawn instead of the text), imageWidth (fraction of the photo's width, 0.01..1; default 0.2)}. Unknown keys and out-of-range sizes are errors"}
}),
&[],
),
Expand Down
2 changes: 2 additions & 0 deletions crates/ui-egui/locales/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -657,6 +657,7 @@
"History & Activity (Y)": "Verlauf und Aktivität (Y)",
"Home": "Persönlicher Ordner",
"Horizontal": "Horizontal",
"Horizontal inset (% of short edge)": "Horizontaler Abstand (% der kurzen Kante)",
"Horizontal text": "Horizontaler Text",
"Hours": "Stunden",
"Hue": "Farbton",
Expand Down Expand Up @@ -1562,6 +1563,7 @@
"Versions": "Versionen",
"Versions (Shift+V)": "Versionen (Umschalt+V)",
"Vertical": "Vertikal",
"Vertical inset (% of short edge)": "Vertikaler Abstand (% der kurzen Kante)",
"Vertical text": "Vertikaler Text",
"Vibrance": "Dynamik",
"Videos": "Videos",
Expand Down
2 changes: 2 additions & 0 deletions crates/ui-egui/locales/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -624,6 +624,7 @@
"History & Activity (Y)": "Historial y actividad (Y)",
"Home": "Carpeta personal",
"Horizontal": "Horizontal",
"Horizontal inset (% of short edge)": "Margen horizontal (% del lado corto)",
"Horizontal text": "Texto horizontal",
"Hours": "Horas",
"How to install the model": "Cómo instalar el modelo",
Expand Down Expand Up @@ -1501,6 +1502,7 @@
"Versions": "Versiones",
"Versions (Shift+V)": "Versiones (Mayús+V)",
"Vertical": "Vertical",
"Vertical inset (% of short edge)": "Margen vertical (% del lado corto)",
"Vertical text": "Texto vertical",
"Vibrance": "Intensidad",
"Videos": "Vídeos",
Expand Down
2 changes: 2 additions & 0 deletions crates/ui-egui/locales/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -624,6 +624,7 @@
"History & Activity (Y)": "Historique et activité (Y)",
"Home": "Dossier personnel",
"Horizontal": "Horizontal",
"Horizontal inset (% of short edge)": "Marge horizontale (% du petit côté)",
"Horizontal text": "Texte horizontal",
"Hours": "Heures",
"How to install the model": "Comment installer le modèle",
Expand Down Expand Up @@ -1499,6 +1500,7 @@
"Versions": "Versions",
"Versions (Shift+V)": "Versions (Maj+V)",
"Vertical": "Vertical",
"Vertical inset (% of short edge)": "Marge verticale (% du petit côté)",
"Vertical text": "Texte vertical",
"Vibrance": "Vibrance",
"Videos": "Vidéos",
Expand Down
2 changes: 2 additions & 0 deletions crates/ui-egui/locales/ja.json
Original file line number Diff line number Diff line change
Expand Up @@ -507,6 +507,7 @@
"Has GPS": "GPS情報",
"High Contrast B&W": "ハイコントラスト白黒",
"Home": "ホーム",
"Horizontal inset (% of short edge)": "水平方向の余白(短辺に対する%)",
"Hours": "時間",
"ISO Speed": "ISO感度",
"ISO speed": "ISO感度",
Expand Down Expand Up @@ -1421,6 +1422,7 @@
"Versions": "バージョン",
"Versions (Shift+V)": "バージョン(⇧V)",
"Vertical": "垂直",
"Vertical inset (% of short edge)": "垂直方向の余白(短辺に対する%)",
"Vibrance": "自然な彩度",
"Videos": "動画",
"View": "表示",
Expand Down
2 changes: 2 additions & 0 deletions crates/ui-egui/locales/pt-br.json
Original file line number Diff line number Diff line change
Expand Up @@ -630,6 +630,7 @@
"History & Activity (Y)": "Histórico e atividade (Y)",
"Home": "Pasta pessoal",
"Horizontal": "Horizontal",
"Horizontal inset (% of short edge)": "Margem horizontal (% da aresta curta)",
"Horizontal text": "Texto horizontal",
"Hours": "Horas",
"How to install the model": "Como instalar o modelo",
Expand Down Expand Up @@ -1512,6 +1513,7 @@
"Versions": "Versões",
"Versions (Shift+V)": "Versões (Shift+V)",
"Vertical": "Vertical",
"Vertical inset (% of short edge)": "Margem vertical (% da aresta curta)",
"Vertical text": "Texto vertical",
"Vibrance": "Intensidade",
"Videos": "Vídeos",
Expand Down
2 changes: 2 additions & 0 deletions crates/ui-egui/locales/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -519,6 +519,7 @@
"History": "История",
"History & Activity (Y)": "История и активность (Y)",
"Horizontal": "По горизонтали",
"Horizontal inset (% of short edge)": "Отступ по горизонтали (% от короткой стороны)",
"Horizontal text": "Горизонтальный текст",
"How to install the model": "Как установить модель",
"Hue": "Тон",
Expand Down Expand Up @@ -1258,6 +1259,7 @@
"Versions": "Версии",
"Versions (Shift+V)": "Версии (Shift+V)",
"Vertical": "По вертикали",
"Vertical inset (% of short edge)": "Отступ по вертикали (% от короткой стороны)",
"Vertical text": "Вертикальный текст",
"Vibrance": "Красочность",
"Videos": "Видео",
Expand Down
2 changes: 2 additions & 0 deletions crates/ui-egui/locales/uk.json
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@
"Grab bag": "Випадкова добірка",
"Group name": "Назва групи",
"Home": "Домашня тека",
"Horizontal inset (% of short edge)": "Відступ по горизонталі (% короткого краю)",
"ISO Speed": "Чутливість ISO",
"Imported": "Імпортовані",
"Join the ArtCraft Discord": "Приєднатися до Discord ArtCraft",
Expand Down Expand Up @@ -294,6 +295,7 @@
"Variance": "Дисперсія",
"Version": "Версія",
"Vertical": "Вертикальна",
"Vertical inset (% of short edge)": "Відступ по вертикалі (% короткого краю)",
"Vibrance": "Соковитість",
"View": "Вигляд",
"Vignetting": "Віньєтування",
Expand Down
2 changes: 2 additions & 0 deletions crates/ui-egui/locales/zh-hans.json
Original file line number Diff line number Diff line change
Expand Up @@ -513,6 +513,7 @@
"Has Edits": "有编辑",
"Has GPS": "有 GPS",
"Home": "主文件夹",
"Horizontal inset (% of short edge)": "水平边距 (占短边 %)",
"Hours": "小时",
"ISO Speed": "ISO 感光度",
"ISO speed": "ISO 感光度",
Expand Down Expand Up @@ -1495,6 +1496,7 @@
"Versions": "版本",
"Versions (Shift+V)": "版本 (Shift+V)",
"Vertical": "垂直",
"Vertical inset (% of short edge)": "垂直边距 (占短边 %)",
"Vertical text": "竖排文字",
"Vibrance": "鲜艳度",
"Videos": "视频",
Expand Down
2 changes: 2 additions & 0 deletions crates/ui-egui/locales/zh-hant.json
Original file line number Diff line number Diff line change
Expand Up @@ -513,6 +513,7 @@
"Has Edits": "有編輯",
"Has GPS": "有 GPS",
"Home": "個人資料夾",
"Horizontal inset (% of short edge)": "水平邊距(短邊百分比)",
"Hours": "小時",
"ISO Speed": "ISO 感光度",
"ISO speed": "ISO 感光度",
Expand Down Expand Up @@ -1495,6 +1496,7 @@
"Versions": "版本",
"Versions (Shift+V)": "版本(Shift+V)",
"Vertical": "垂直",
"Vertical inset (% of short edge)": "垂直邊距(短邊百分比)",
"Vertical text": "垂直文字",
"Vibrance": "自然飽和度",
"Videos": "影片",
Expand Down
52 changes: 50 additions & 2 deletions crates/ui-egui/src/panels/dialogs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,7 @@ pub fn show(app: &mut LightcraftApp, ctx: &egui::Context) {
ui.label("Choose a PDF destination after confirming. Print the PDF from your viewer.");
}
Dialog::Export { opts, full_size, resize, preset_name, limit_kb, dir } => {
use lightcraft_engine::export::{Anchor as P, ExportFormat as F, MetadataPolicy as M, SharpenAmount as A, SharpenFor as S};
use lightcraft_engine::export::{ExportFormat as F, MetadataPolicy as M, SharpenAmount as A, SharpenFor as S};
let n = app.session.selection.ids.len().max(1);
ui.label(egui::RichText::new(crate::i18n::tr_format!("{n} photo{}", if n == 1 { "" } else { "s" }, n = n)).color(t.text_dim));
// Preset: load a built-in or saved set of options into the dialog
Expand Down Expand Up @@ -666,9 +666,10 @@ pub fn show(app: &mut LightcraftApp, ctx: &egui::Context) {
ui,
"Position",
"exportWmAnchor",
&[(P::TopLeft, "↖"), (P::TopRight, "↗"), (P::Center, "•"), (P::BottomLeft, "↙"), (P::BottomRight, "↘")],
&WM_POSITIONS,
&mut wm.anchor,
);
choices(ui, "Rotate", "exportWmRotation", &[(0u16, "0°"), (90, "90°"), (180, "180°"), (270, "270°")], &mut wm.rotation);
let mut size = wm.size as f64 * 100.0;
if !graphic && num(ui, &WM_SIZE, &mut size) {
wm.size = (size / 100.0) as f32;
Expand All @@ -677,6 +678,17 @@ pub fn show(app: &mut LightcraftApp, ctx: &egui::Context) {
if num(ui, &WM_OPACITY, &mut op) {
wm.opacity = (op / 100.0) as f32;
}
// like Lightroom Classic: a margin from the side edges and one from the top and bottom
// edges, each unused (greyed) when the position is centred along that axis
use lightcraft_engine::export::Anchor as P;
let across = !matches!(wm.anchor, P::Top | P::Center | P::Bottom);
if let Some(v) = crate::widgets::slider(ui, &WM_INSET_X, wm.inset_x as f64 * 100.0, across, None).value {
wm.inset_x = (v / 100.0) as f32;
}
let down = !matches!(wm.anchor, P::Left | P::Center | P::Right);
if let Some(v) = crate::widgets::slider(ui, &WM_INSET_Y, wm.inset_y as f64 * 100.0, down, None).value {
wm.inset_y = (v / 100.0) as f32;
}
if !graphic {
ui.checkbox(&mut wm.shadow, crate::i18n::tr("Shadow"));
}
Expand Down Expand Up @@ -1508,9 +1520,20 @@ fn export_size(ui: &mut egui::Ui, full: &mut bool, r: &mut lightcraft_engine::ex
*ppi = p as u16;
}
}
/// All nine positions supported by both the text and graphic watermark renderer.
/// Keep them in grid order so bottom-centre and edge-centre anchors are available in Export.
const WM_POSITIONS: [(lightcraft_engine::export::Anchor, &str); 9] = {
use lightcraft_engine::export::Anchor::*;
[(TopLeft, "↖"), (Top, "↑"), (TopRight, "↗"), (Left, "←"), (Center, "•"), (Right, "→"), (BottomLeft, "↙"), (Bottom, "↓"), (BottomRight, "↘")]
};

const WM_IMAGE_WIDTH: ControlSpec = spec("export.watermarkImageWidth", "Width (% of photo)", 2.0, 100.0, 20.0, 1.0);
const WM_SIZE: ControlSpec = spec("export.watermarkSize", "Size (% of short edge)", 1.0, 15.0, 3.5, 0.5);
const WM_OPACITY: ControlSpec = spec("export.watermarkOpacity", "Opacity (%)", 5.0, 100.0, 70.0, 1.0);
const WM_INSET_X: ControlSpec =
ControlSpec { decimals: 1, ..spec("export.watermarkInsetX", "Horizontal inset (% of short edge)", 0.0, 40.0, 2.5, 0.5) };
const WM_INSET_Y: ControlSpec =
ControlSpec { decimals: 1, ..spec("export.watermarkInsetY", "Vertical inset (% of short edge)", 0.0, 40.0, 2.5, 0.5) };

/// A themed slider row editing `v`; true when it changed.
fn num(ui: &mut egui::Ui, spec: &ControlSpec, v: &mut f64) -> bool {
Expand Down Expand Up @@ -1577,3 +1600,28 @@ fn just_opened(ui: &egui::Ui, key: &str) -> bool {
ui.data_mut(|d| d.insert_temp(id, pass));
last.and_then(|l| l.checked_add(1)) != Some(pass)
}

#[cfg(test)]
mod watermark_position_tests {
use super::WM_POSITIONS;
use lightcraft_engine::export::Anchor;

#[test]
fn export_dialog_offers_every_rendered_anchor_exactly_once() {
let anchors = [
Anchor::TopLeft,
Anchor::Top,
Anchor::TopRight,
Anchor::Left,
Anchor::Center,
Anchor::Right,
Anchor::BottomLeft,
Anchor::Bottom,
Anchor::BottomRight,
];
assert_eq!(WM_POSITIONS.len(), anchors.len());
for anchor in anchors {
assert_eq!(WM_POSITIONS.iter().filter(|(position, _)| *position == anchor).count(), 1);
}
}
}
Loading