Free, open-source file converter. Convert 263 formats offline by drag & drop — images, PDF, Word, Excel, PowerPoint, HWP/HWPX, video, audio, e-books and archives. No upload, no Office needed.
C# audio-converteravaloniabatch-conversionconvertercsharpdocument-converterdocx-to-pdfdotnetdrag-and-dropfile-conversionfile-converterheic-converterhwphwpximage-converterlinuxmacospdf-convertervideo-converterwindows
Edit pictures: the size shown as written, long names fit, Enter converts
KnifeLemon29f57a0ac2ff
diff --git a/src/Filee.App/Assets/i18n/ar.json b/src/Filee.App/Assets/i18n/ar.jsonindex 67f43865..a2758806 100644--- a/src/Filee.App/Assets/i18n/ar.json+++ b/src/Filee.App/Assets/i18n/ar.json@@ -310,11 +310,12 @@"clip.no_silence": "لم يُعثر على صمت","clip.cannot_play": "لا يمكن تشغيل المقطع","preset.half_size": "نصف الحجم",+ "preset.half_size.donut": "نصف الحجم","preset.image_edit": "تعديل الصور",- "image_edit.count": "{0} صور",+ "preset.image_edit.donut": "تعديل الصور",+ "image_edit.count": "الصور: {0}","image_edit.hint": "اختر الحجم والتنسيق والتدوير لهذه الصور. يحتفظ Filee باختياراتك للمرة القادمة.","image_edit.convert": "تحويل",- "preset.half_size.donut": "نصف الحجم","preset.grayscale": "تدرّج رمادي","preset.remove_background": "إزالة الخلفية","preset.trim_transparent": "قص الحواف الشفافة",diff --git a/src/Filee.App/Assets/i18n/de.json b/src/Filee.App/Assets/i18n/de.jsonindex 763ad32b..7fa05e79 100644--- a/src/Filee.App/Assets/i18n/de.json+++ b/src/Filee.App/Assets/i18n/de.json@@ -310,11 +310,12 @@"clip.no_silence": "Keine Stille gefunden","clip.cannot_play": "Der Clip lässt sich nicht abspielen","preset.half_size": "Halbe Größe",+ "preset.half_size.donut": "Halbe Größe","preset.image_edit": "Bilder bearbeiten",+ "preset.image_edit.donut": "Bilder bearbeiten","image_edit.count": "{0} Bilder","image_edit.hint": "Wähle Größe, Format und Drehung für diese Bilder. Filee merkt sich deine Wahl für das nächste Mal.","image_edit.convert": "Konvertieren",- "preset.half_size.donut": "Halbe Größe","preset.grayscale": "Graustufen","preset.remove_background": "Hintergrund entfernen","preset.trim_transparent": "Transparente Ränder abschneiden",diff --git a/src/Filee.App/Assets/i18n/en.json b/src/Filee.App/Assets/i18n/en.jsonindex 2580bf46..207cc671 100644--- a/src/Filee.App/Assets/i18n/en.json+++ b/src/Filee.App/Assets/i18n/en.json@@ -320,11 +320,12 @@"clip.cannot_play": "The clip can't be played","preset.half_size": "Half size",+ "preset.half_size.donut": "Half size","preset.image_edit": "Edit pictures",+ "preset.image_edit.donut": "Edit pictures","image_edit.count": "{0} pictures",- "image_edit.hint": "Choose the size, format and turn for these pictures. Filee keeps your choices for the next time.",+ "image_edit.hint": "Choose the size, format and rotation of these pictures. Filee keeps your choices for next time.","image_edit.convert": "Convert",- "preset.half_size.donut": "Half size","preset.grayscale": "Grayscale","preset.remove_background": "Remove background","preset.trim_transparent": "Trim transparent borders",diff --git a/src/Filee.App/Assets/i18n/es.json b/src/Filee.App/Assets/i18n/es.jsonindex e91680fb..ad8eec35 100644--- a/src/Filee.App/Assets/i18n/es.json+++ b/src/Filee.App/Assets/i18n/es.json@@ -310,11 +310,12 @@"clip.no_silence": "No se encontraron silencios","clip.cannot_play": "No se puede reproducir el clip","preset.half_size": "Reducir 50 %",+ "preset.half_size.donut": "Reducir 50 %","preset.image_edit": "Editar imágenes",+ "preset.image_edit.donut": "Editar imágenes","image_edit.count": "{0} imágenes",- "image_edit.hint": "Elige el tamaño, el formato y el giro de estas imágenes. Filee recuerda tu elección para la próxima vez.",+ "image_edit.hint": "Elige el tamaño, el formato y la rotación de estas imágenes. Filee recuerda tu elección para la próxima vez.","image_edit.convert": "Convertir",- "preset.half_size.donut": "Reducir 50 %","preset.grayscale": "Grises","preset.remove_background": "Quitar fondo","preset.trim_transparent": "Recortar bordes transparentes",diff --git a/src/Filee.App/Assets/i18n/fr.json b/src/Filee.App/Assets/i18n/fr.jsonindex 401e67e1..886a53fb 100644--- a/src/Filee.App/Assets/i18n/fr.json+++ b/src/Filee.App/Assets/i18n/fr.json@@ -320,11 +320,12 @@"clip.cannot_play": "Impossible de lire l'extrait","preset.half_size": "Taille 50 %",+ "preset.half_size.donut": "Taille 50 %","preset.image_edit": "Modifier les images",+ "preset.image_edit.donut": "Modifier","image_edit.count": "{0} images","image_edit.hint": "Choisissez la taille, le format et la rotation de ces images. Filee garde vos choix pour la prochaine fois.","image_edit.convert": "Convertir",- "preset.half_size.donut": "Taille 50 %","preset.grayscale": "Niveaux de gris","preset.remove_background": "Détourer","preset.trim_transparent": "Rogner les bords transparents",diff --git a/src/Filee.App/Assets/i18n/hi.json b/src/Filee.App/Assets/i18n/hi.jsonindex 93c06a22..482af71c 100644--- a/src/Filee.App/Assets/i18n/hi.json+++ b/src/Filee.App/Assets/i18n/hi.json@@ -310,11 +310,12 @@"clip.no_silence": "कोई चुप्पी नहीं मिली","clip.cannot_play": "क्लिप नहीं चल सकती","preset.half_size": "आधा आकार",- "preset.image_edit": "चित्र संपादित करें",- "image_edit.count": "{0} चित्र",- "image_edit.hint": "इन चित्रों का आकार, फ़ॉर्मेट और घुमाव चुनें। Filee अगली बार के लिए आपकी पसंद याद रखता है।",- "image_edit.convert": "कन्वर्ट करें","preset.half_size.donut": "आधा आकार",+ "preset.image_edit": "इमेज संपादित करें",+ "preset.image_edit.donut": "संपादन",+ "image_edit.count": "{0} इमेज",+ "image_edit.hint": "इन इमेज का आकार, फ़ॉर्मेट और घुमाव चुनें। Filee अगली बार के लिए आपकी पसंद याद रखता है।",+ "image_edit.convert": "कन्वर्ट करें","preset.grayscale": "ग्रेस्केल","preset.remove_background": "बैकग्राउंड हटाएँ","preset.trim_transparent": "पारदर्शी किनारे काटें",diff --git a/src/Filee.App/Assets/i18n/ja.json b/src/Filee.App/Assets/i18n/ja.jsonindex 548fbc25..210b5cef 100644--- a/src/Filee.App/Assets/i18n/ja.json+++ b/src/Filee.App/Assets/i18n/ja.json@@ -310,11 +310,12 @@"clip.no_silence": "無音は見つかりませんでした","clip.cannot_play": "クリップを再生できません","preset.half_size": "縮小 50%",+ "preset.half_size.donut": "縮小 50%","preset.image_edit": "画像を編集",+ "preset.image_edit.donut": "画像を編集","image_edit.count": "{0} 枚の画像","image_edit.hint": "この画像のサイズ、形式、回転を選んでください。選んだ内容は次回も使われます。","image_edit.convert": "変換",- "preset.half_size.donut": "縮小 50%","preset.grayscale": "グレースケール","preset.remove_background": "背景を削除","preset.trim_transparent": "透明な余白を切り取る",diff --git a/src/Filee.App/Assets/i18n/ko.json b/src/Filee.App/Assets/i18n/ko.jsonindex 09fdce3d..44081c03 100644--- a/src/Filee.App/Assets/i18n/ko.json+++ b/src/Filee.App/Assets/i18n/ko.json@@ -320,11 +320,12 @@"clip.cannot_play": "클립을 재생할 수 없어요","preset.half_size": "50% 축소",- "preset.image_edit": "사진 편집",- "image_edit.count": "사진 {0}장",- "image_edit.hint": "이 사진들의 크기, 형식, 회전을 고르세요. 고른 값은 다음에도 그대로 쓰입니다.",- "image_edit.convert": "변환","preset.half_size.donut": "50% 축소",+ "preset.image_edit": "이미지 편집",+ "preset.image_edit.donut": "이미지 편집",+ "image_edit.count": "이미지 {0}개",+ "image_edit.hint": "이 이미지들의 크기, 형식, 회전을 고르세요. 고른 값은 다음에도 그대로 쓰여요.",+ "image_edit.convert": "변환","preset.grayscale": "흑백","preset.remove_background": "배경 제거","preset.trim_transparent": "투명 여백 자르기",diff --git a/src/Filee.App/Assets/i18n/ne.json b/src/Filee.App/Assets/i18n/ne.jsonindex 7dedf719..fe0e5025 100644--- a/src/Filee.App/Assets/i18n/ne.json+++ b/src/Filee.App/Assets/i18n/ne.json@@ -310,11 +310,12 @@"clip.no_silence": "मौनता भेटिएन","clip.cannot_play": "क्लिप बजाउन सकिँदैन","preset.half_size": "आधा आकार",- "preset.image_edit": "तस्बिरहरू सम्पादन गर्नुहोस्",- "image_edit.count": "{0} तस्बिरहरू",- "image_edit.hint": "यी तस्बिरहरूको आकार, ढाँचा र घुमाइ छान्नुहोस्। Filee ले अर्को पटकका लागि तपाईंको छनोट सम्झन्छ।",- "image_edit.convert": "रूपान्तरण गर्नुहोस्","preset.half_size.donut": "आधा आकार",+ "preset.image_edit": "छविहरू सम्पादन गर्नुहोस्",+ "preset.image_edit.donut": "सम्पादन",+ "image_edit.count": "छविहरू: {0}",+ "image_edit.hint": "यी छविहरूको आकार, ढाँचा र घुमाइ छान्नुहोस्। Filee ले अर्को पटकका लागि तपाईंको छनोट सम्झन्छ।",+ "image_edit.convert": "रूपान्तरण गर्नुहोस्","preset.grayscale": "ग्रेस्केल","preset.remove_background": "पृष्ठभूमि हटाउनुहोस्","preset.trim_transparent": "पारदर्शी किनारा काट्नुहोस्",diff --git a/src/Filee.App/Assets/i18n/pl.json b/src/Filee.App/Assets/i18n/pl.jsonindex 57298326..c8a6e50a 100644--- a/src/Filee.App/Assets/i18n/pl.json+++ b/src/Filee.App/Assets/i18n/pl.json@@ -320,11 +320,12 @@"clip.cannot_play": "Nie można odtworzyć klipu","preset.half_size": "Połowa rozmiaru",+ "preset.half_size.donut": "Połowa rozmiaru","preset.image_edit": "Edytuj obrazy",+ "preset.image_edit.donut": "Edytuj obrazy","image_edit.count": "Obrazy: {0}","image_edit.hint": "Wybierz rozmiar, format i obrót tych obrazów. Filee zapamięta wybór na następny raz.","image_edit.convert": "Konwertuj",- "preset.half_size.donut": "Połowa rozmiaru","preset.grayscale": "Skala szarości","preset.remove_background": "Usuń tło","preset.trim_transparent": "Przytnij przezroczyste brzegi",diff --git a/src/Filee.App/Assets/i18n/pt-BR.json b/src/Filee.App/Assets/i18n/pt-BR.jsonindex 18498e37..a5288699 100644--- a/src/Filee.App/Assets/i18n/pt-BR.json+++ b/src/Filee.App/Assets/i18n/pt-BR.json@@ -320,11 +320,12 @@"clip.cannot_play": "Não foi possível reproduzir o clipe","preset.half_size": "Reduzir 50%",+ "preset.half_size.donut": "Tamanho 50%","preset.image_edit": "Editar imagens",+ "preset.image_edit.donut": "Editar imagens","image_edit.count": "{0} imagens","image_edit.hint": "Escolha o tamanho, o formato e a rotação dessas imagens. O Filee guarda suas escolhas para a próxima vez.","image_edit.convert": "Converter",- "preset.half_size.donut": "Tamanho 50%","preset.grayscale": "Tons de cinza","preset.remove_background": "Remover fundo","preset.trim_transparent": "Cortar bordas transparentes",diff --git a/src/Filee.App/Assets/i18n/pt-PT.json b/src/Filee.App/Assets/i18n/pt-PT.jsonindex 468c6216..6aba330c 100644--- a/src/Filee.App/Assets/i18n/pt-PT.json+++ b/src/Filee.App/Assets/i18n/pt-PT.json@@ -320,11 +320,12 @@"clip.cannot_play": "Não é possível reproduzir o excerto","preset.half_size": "Metade do tamanho",+ "preset.half_size.donut": "Tamanho 50%","preset.image_edit": "Editar imagens",+ "preset.image_edit.donut": "Editar imagens","image_edit.count": "{0} imagens","image_edit.hint": "Escolha o tamanho, o formato e a rotação destas imagens. O Filee guarda as suas escolhas para a próxima vez.","image_edit.convert": "Converter",- "preset.half_size.donut": "Tamanho 50%","preset.grayscale": "Escala de cinzentos","preset.remove_background": "Remover fundo","preset.trim_transparent": "Recortar margens transparentes",diff --git a/src/Filee.App/Assets/i18n/ru.json b/src/Filee.App/Assets/i18n/ru.jsonindex 314878f7..f6a085b6 100644--- a/src/Filee.App/Assets/i18n/ru.json+++ b/src/Filee.App/Assets/i18n/ru.json@@ -320,11 +320,12 @@"clip.cannot_play": "Клип не воспроизводится","preset.half_size": "Вдвое меньше",+ "preset.half_size.donut": "Вдвое меньше","preset.image_edit": "Изменить изображения",+ "preset.image_edit.donut": "Изменить","image_edit.count": "Изображений: {0}","image_edit.hint": "Выберите размер, формат и поворот для этих изображений. Filee запомнит выбор на следующий раз.","image_edit.convert": "Преобразовать",- "preset.half_size.donut": "Вдвое меньше","preset.grayscale": "Оттенки серого","preset.remove_background": "Убрать фон","preset.trim_transparent": "Обрезать прозрачные края",diff --git a/src/Filee.App/Assets/i18n/th.json b/src/Filee.App/Assets/i18n/th.jsonindex cadf8df8..fdd21a0b 100644--- a/src/Filee.App/Assets/i18n/th.json+++ b/src/Filee.App/Assets/i18n/th.json@@ -310,11 +310,12 @@"clip.no_silence": "ไม่พบช่วงเงียบ","clip.cannot_play": "เล่นคลิปนี้ไม่ได้","preset.half_size": "ขนาดครึ่งหนึ่ง",+ "preset.half_size.donut": "ขนาดครึ่งหนึ่ง","preset.image_edit": "แก้ไขรูปภาพ",+ "preset.image_edit.donut": "แก้ไขภาพ","image_edit.count": "รูปภาพ {0} รูป","image_edit.hint": "เลือกขนาด รูปแบบ และการหมุนของรูปภาพเหล่านี้ Filee จะจำตัวเลือกไว้ใช้ครั้งหน้า","image_edit.convert": "แปลง",- "preset.half_size.donut": "ขนาดครึ่งหนึ่ง","preset.grayscale": "ขาวดำ (เกรย์สเกล)","preset.remove_background": "ลบพื้นหลัง","preset.trim_transparent": "ตัดขอบโปร่งใส",diff --git a/src/Filee.App/Assets/i18n/tr.json b/src/Filee.App/Assets/i18n/tr.jsonindex 1e827e91..733fcbd3 100644--- a/src/Filee.App/Assets/i18n/tr.json+++ b/src/Filee.App/Assets/i18n/tr.json@@ -310,11 +310,12 @@"clip.no_silence": "Sessiz kısım bulunamadı","clip.cannot_play": "Klip oynatılamıyor","preset.half_size": "Yarı boyut",- "preset.image_edit": "Resimleri düzenle",- "image_edit.count": "{0} resim",- "image_edit.hint": "Bu resimlerin boyutunu, biçimini ve dönüşünü seçin. Filee seçimlerinizi bir dahaki sefere hatırlar.",- "image_edit.convert": "Dönüştür","preset.half_size.donut": "Yarı boyut",+ "preset.image_edit": "Görselleri düzenle",+ "preset.image_edit.donut": "Görselleri düzenle",+ "image_edit.count": "{0} görsel",+ "image_edit.hint": "Bu görsellerin boyutunu, biçimini ve yönünü seçin. Filee seçimlerinizi bir dahaki sefere hatırlar.",+ "image_edit.convert": "Dönüştür","preset.grayscale": "Gri tonlama","preset.remove_background": "Arka planı kaldır","preset.trim_transparent": "Saydam kenarları kırp",diff --git a/src/Filee.App/Assets/i18n/zh-CN.json b/src/Filee.App/Assets/i18n/zh-CN.jsonindex 49f5b1da..7b88a10c 100644--- a/src/Filee.App/Assets/i18n/zh-CN.json+++ b/src/Filee.App/Assets/i18n/zh-CN.json@@ -320,11 +320,12 @@"clip.cannot_play": "无法播放片段","preset.half_size": "缩小 50%",+ "preset.half_size.donut": "缩小 50%","preset.image_edit": "编辑图片",+ "preset.image_edit.donut": "编辑图片","image_edit.count": "{0} 张图片","image_edit.hint": "为这些图片选择尺寸、格式和旋转。Filee 会记住你的选择,下次继续使用。","image_edit.convert": "转换",- "preset.half_size.donut": "缩小 50%","preset.grayscale": "灰度","preset.remove_background": "去除背景","preset.trim_transparent": "裁掉透明边框",diff --git a/src/Filee.App/Assets/i18n/zh-TW.json b/src/Filee.App/Assets/i18n/zh-TW.jsonindex 29f2ffa4..6a924ef7 100644--- a/src/Filee.App/Assets/i18n/zh-TW.json+++ b/src/Filee.App/Assets/i18n/zh-TW.json@@ -320,11 +320,12 @@"clip.cannot_play": "無法播放片段","preset.half_size": "縮小 50%",+ "preset.half_size.donut": "縮小 50%","preset.image_edit": "編輯圖片",+ "preset.image_edit.donut": "編輯圖片","image_edit.count": "{0} 張圖片","image_edit.hint": "為這些圖片選擇尺寸、格式和旋轉。Filee 會記住你的選擇,下次繼續使用。","image_edit.convert": "轉換",- "preset.half_size.donut": "縮小 50%","preset.grayscale": "灰階","preset.remove_background": "去除背景","preset.trim_transparent": "裁掉透明邊框",diff --git a/src/Filee.App/Services/WindowService.cs b/src/Filee.App/Services/WindowService.csindex bfff8855..be014fac 100644--- a/src/Filee.App/Services/WindowService.cs+++ b/src/Filee.App/Services/WindowService.cs@@ -123,8 +123,8 @@ public sealed class WindowService(ILocalizer loc, IServiceProvider services, Mempublic MainWindow? Main => _main;/// <summary>- /// Opens the window of a tool preset (crop, cut a clip, the spreadsheet print studio: one per workbook, the PDF page- /// editor) on the files. A tool this version doesn't know opens nothing.+ /// Opens the window of a tool preset (crop, cut a clip, edit pictures, the spreadsheet print studio: one per workbook,+ /// the PDF page editor) on the files. A tool this version doesn't know opens nothing./// </summary>public void ShowTool(IReadOnlyList<string> files, Preset preset, PixelPoint? near = null){@@ -192,9 +192,10 @@ public sealed class WindowService(ILocalizer loc, IServiceProvider services, Memvar conversions = services.GetRequiredService<ConversionService>();var log = services.GetService<ILogger<ImageEditViewModel>>();var planner = catalog.CreatePlanner();+ var formats = pictures.Select(path => FormatRegistry.Detect(path)?.Id ?? "").ToList();var vm = new ImageEditViewModel(pictures, preset, loc, store,(path, chosen) => ImageEditTool.TargetFor(FormatRegistry.Detect(path)?.Id ?? "", chosen, planner),- (paths, conversion) => conversions.Start(paths, conversion), PictureSize, log);+ (paths, conversion) => conversions.Start(paths, conversion), PictureSize, log, ImageEditTool.TargetsFrom(formats, planner));var win = new ImageEditWindow { DataContext = vm };PrepareWindow(win);win.Closed += (_, _) =>@@ -207,13 +208,21 @@ public sealed class WindowService(ILocalizer loc, IServiceProvider services, Memwin.Activate();}- /// <summary>The pixel size of a picture, read from its header; null when ImageMagick can't read it.</summary>- private static (int Width, int Height)? PictureSize(string path)+ /// <summary>+ /// The pixel size of a picture as it is seen, read from its headers: turned as its EXIF orientation says, and the+ /// largest of an icon's sizes (the one converted). Null when ImageMagick can't read it.+ /// </summary>+ internal static (int Width, int Height)? PictureSize(string path){try{- var info = new ImageMagick.MagickImageInfo(path);- return ((int)info.Width, (int)info.Height);+ var info = ImageMagick.MagickImageInfo.ReadCollection(path).MaxBy(frame => (long)frame.Width * frame.Height);+ if (info is null)+ return null;+ return info.Orientation is ImageMagick.OrientationType.LeftTop or ImageMagick.OrientationType.RightTop+ or ImageMagick.OrientationType.RightBottom or ImageMagick.OrientationType.LeftBottom+ ? ((int)info.Height, (int)info.Width)+ : ((int)info.Width, (int)info.Height);}catch (Exception ex) when (ex is ImageMagick.MagickException or IOException or UnauthorizedAccessException){diff --git a/src/Filee.App/ViewModels/ImageEditViewModel.cs b/src/Filee.App/ViewModels/ImageEditViewModel.csindex 3a52442f..d2b992d2 100644--- a/src/Filee.App/ViewModels/ImageEditViewModel.cs+++ b/src/Filee.App/ViewModels/ImageEditViewModel.cs@@ -14,6 +14,9 @@ namespace Filee.App.ViewModels;public sealed partial class ImageEditViewModel : ObservableObject{+ /// <summary>File names listed in the heading's tooltip before "…".</summary>+ private const int NamesInTip = 12;+private readonly Preset _tool;private readonly ILocalizer _loc;private readonly UserDataStore _store;@@ -21,15 +24,21 @@ public sealed partial class ImageEditViewModel : ObservableObjectprivate readonly Action<IReadOnlyList<string>, Preset> _start;private readonly ILogger? _log;private readonly (int Width, int Height)? _firstSize;+ private readonly IReadOnlyList<string> _sourceFormats;+ private readonly bool _keepsLossyFormat;/// <param name="pictures">The pictures to convert (other files are left out by the caller).</param>/// <param name="tool">The "Edit pictures" tool: its last choices, name and output rule.</param>/// <param name="targetFor">The format a picture (path) is written in for the chosen one (<see cref="ImageEditTool.TargetFor"/>).</param>/// <param name="start">Starts the conversion of some of the pictures.</param>- /// <param name="sizeOf">The pixel size of a picture, null when it can't be read; for the size shown in the window.</param>+ /// <param name="sizeOf">+ /// The pixel size of a picture as it is seen (EXIF orientation applied), null when it can't be read; for the size+ /// shown in the window.+ /// </param>+ /// <param name="targets">The formats offered after "Same format" (<see cref="ImageEditTool.TargetsFrom"/>); all by default.</param>public ImageEditViewModel(IReadOnlyList<string> pictures, Preset tool, ILocalizer loc, UserDataStore store,Func<string, string, string> targetFor, Action<IReadOnlyList<string>, Preset> start,- Func<string, (int Width, int Height)?>? sizeOf = null, ILogger? log = null)+ Func<string, (int Width, int Height)?>? sizeOf = null, ILogger? log = null, IReadOnlyList<string>? targets = null){Pictures = pictures;_tool = tool;@@ -38,14 +47,17 @@ public sealed partial class ImageEditViewModel : ObservableObject_targetFor = targetFor;_start = start;_log = log;- _firstSize = pictures.Count > 0 ? sizeOf?.Invoke(pictures[0]) : null;+ _firstSize = pictures.Count > 0 && sizeOf?.Invoke(pictures[0]) is { Width: > 0, Height: > 0 } size ? size : null;+ _sourceFormats = pictures.Select(path => FormatRegistry.Detect(path)?.Id ?? "").ToList();+ _keepsLossyFormat = pictures.Where((path, i) => ImageEditTool.LossyTargets.Contains(_sourceFormats[i])+ && targetFor(path, BuiltInData.SameAsSource) == BuiltInData.SameAsSource).Any();Targets =[new Choice<string>(BuiltInData.SameAsSource, loc["presets.same_as_source"]),- .. ImageEditTool.Targets.Select(id => new Choice<string>(id, FormatRegistry.Get(id).DisplayName)),+ .. (targets ?? ImageEditTool.Targets).Select(id => new Choice<string>(id, FormatRegistry.Get(id).DisplayName)),];- ResizeModes = Enum.GetValues<ResizeMode>().Select(v => new Choice<ResizeMode>(v, loc[$"presets.resize.{v}"])).ToList();+ ResizeModes = ImageEditTool.ResizeModes.Select(v => new Choice<ResizeMode>(v, loc[$"presets.resize.{v}"])).ToList();Rotations = Enum.GetValues<ImageRotation>().Select(v => new Choice<ImageRotation>(v, loc[$"presets.rotation.{v}"])).ToList();Flips = Enum.GetValues<ImageFlip>().Select(v => new Choice<ImageFlip>(v, loc[$"presets.flip.{v}"])).ToList();@@ -69,29 +81,29 @@ public sealed partial class ImageEditViewModel : ObservableObjectpublic IReadOnlyList<Choice<ImageFlip>> Flips { get; }[ObservableProperty]- [NotifyPropertyChangedFor(nameof(ShowQuality))]+ [NotifyPropertyChangedFor(nameof(ShowQuality), nameof(SizeAfter))]private Choice<string> _target;[ObservableProperty]- [NotifyPropertyChangedFor(nameof(ShowPercent), nameof(ShowLongEdge), nameof(ShowWidth), nameof(SizeChange))]+ [NotifyPropertyChangedFor(nameof(ShowPercent), nameof(ShowLongEdge), nameof(ShowWidth), nameof(SizeAfter))]private Choice<ResizeMode> _resize;[ObservableProperty]- [NotifyPropertyChangedFor(nameof(SizeChange))]+ [NotifyPropertyChangedFor(nameof(SizeAfter))]private Choice<ImageRotation> _rotation;[ObservableProperty] private Choice<ImageFlip> _flip;[ObservableProperty]- [NotifyPropertyChangedFor(nameof(SizeChange))]+ [NotifyPropertyChangedFor(nameof(SizeAfter))]private int _resizePercent;[ObservableProperty]- [NotifyPropertyChangedFor(nameof(SizeChange))]+ [NotifyPropertyChangedFor(nameof(SizeAfter))]private int _longEdge;[ObservableProperty]- [NotifyPropertyChangedFor(nameof(SizeChange))]+ [NotifyPropertyChangedFor(nameof(SizeAfter))]private int _width;[ObservableProperty] private bool _grayscale;@@ -106,28 +118,47 @@ public sealed partial class ImageEditViewModel : ObservableObjectpublic bool ShowLongEdge => Resize.Value == ResizeMode.LongEdge;public bool ShowWidth => Resize.Value == ResizeMode.Width;- /// <summary>JPG, WEBP, AVIF and HEIC, or the source's own format (which may be one of them).</summary>- public bool ShowQuality => Target.Value == BuiltInData.SameAsSource || ImageEditTool.LossyTargets.Contains(Target.Value);+ /// <summary>+ /// JPG, WEBP, AVIF and HEIC; with "Same format", when one of the pictures is one of them (a PNG has no quality).+ /// </summary>+ public bool ShowQuality => Target.Value == BuiltInData.SameAsSource ? _keepsLossyFormat : ImageEditTool.LossyTargets.Contains(Target.Value);/// <summary>The first picture's name, or how many pictures there are.</summary>public string Heading => Pictures.Count == 1 ? Path.GetFileName(Pictures[0]) : _loc.Format("image_edit.count", Pictures.Count);- /// <summary>"512 × 512 → 32 × 32" for the first picture; empty when its size can't be read.</summary>- public string SizeChange+ /// <summary>The heading's tooltip: the picture's whole path, or the names of the pictures.</summary>+ public string HeadingTip => Pictures.Count == 1+ ? Pictures[0]+ : string.Join('\n', Pictures.Take(NamesInTip).Select(Path.GetFileName)) + (Pictures.Count > NamesInTip ? "\n…" : "");++ /// <summary>The before → after line is shown: the first picture's size could be read.</summary>+ public bool ShowSize => _firstSize is not null;++ /// <summary>The first picture's size, "512 × 256"; empty when it can't be read.</summary>+ public string SizeBefore => _firstSize is { } size ? $"{size.Width} × {size.Height}" : "";++ /// <summary>The size the first picture is written in with the choices, "32 × 16"; empty when it can't be read.</summary>+ public string SizeAfter => SizeOfFirst() is { } size ? $"{size.Width} × {size.Height}" : "";++ /// <summary>+ /// The first picture's size once converted, worked out as the encoder does it: turned, resized, brought within what+ /// the format stores, and for an icon squared and at most 256 px.+ /// </summary>+ internal (int Width, int Height)? SizeOfFirst(){- get- {- if (_firstSize is not { } size || size.Width <= 0 || size.Height <= 0)- return "";- var (width, height) = size;- var options = Options();- var scale = ImageEncoder.ResizeScale(width, height, options);- var turned = options.Rotation is ImageRotation.Left90 or ImageRotation.Right90;- var (outWidth, outHeight) = (Math.Max(1, (int)Math.Round(width * scale)), Math.Max(1, (int)Math.Round(height * scale)));- if (turned)- (outWidth, outHeight) = (outHeight, outWidth);- return $"{width} × {height} → {outWidth} × {outHeight}";- }+ if (_firstSize is not { } size)+ return null;+ var options = Options();+ var (width, height) = options.Rotation is ImageRotation.Left90 or ImageRotation.Right90 ? (size.Height, size.Width) : size;+ var scale = ImageEncoder.ResizeScale(width, height, options);+ (width, height) = (Math.Max(1, (int)Math.Round(width * scale)), Math.Max(1, (int)Math.Round(height * scale)));+ var target = _targetFor(Pictures[0], Target.Value) is var chosen && chosen == BuiltInData.SameAsSource ? _sourceFormats[0] : chosen;+ var fit = Math.Min(1, ImageEncoder.MaxSide(target) / Math.Max(width, height));+ if (fit < 1)+ (width, height) = (Math.Max(1, (int)Math.Floor(width * fit)), Math.Max(1, (int)Math.Floor(height * fit)));+ if (target == "ico")+ width = height = Math.Min(256, Math.Max(width, height));+ return (width, height);}/// <summary>The tool's picture options with the window's choices.</summary>diff --git a/src/Filee.App/Views/ImageEditWindow.axaml b/src/Filee.App/Views/ImageEditWindow.axamlindex a9a0f74f..49cb147c 100644--- a/src/Filee.App/Views/ImageEditWindow.axaml+++ b/src/Filee.App/Views/ImageEditWindow.axaml@@ -7,7 +7,7 @@x:DataType="vm:ImageEditViewModel"Title="{DynamicResource preset.image_edit}"Icon="avares://Filee/Assets/Icons/filee.ico"- Width="480" SizeToContent="Height" MinWidth="400" CanResize="False"+ Width="520" SizeToContent="Height" MinWidth="440" CanResize="False"WindowStartupLocation="CenterScreen"><DockPanel><Border DockPanel.Dock="Bottom" Padding="20,12" BorderThickness="0,1,0,0" BorderBrush="{DynamicResource SubtleBorderBrush}"@@ -19,7 +19,7 @@</Border><StackPanel Margin="20,18,20,16" Spacing="12"><StackPanel Spacing="4">- <TextBlock Classes="h2" Text="{Binding Heading}" TextTrimming="CharacterEllipsis" />+ <TextBlock Classes="h2" Text="{Binding Heading}" TextTrimming="CharacterEllipsis" ToolTip.Tip="{Binding HeadingTip}" /><TextBlock Classes="caption" TextWrapping="Wrap" Text="{DynamicResource image_edit.hint}" /></StackPanel>@@ -29,7 +29,7 @@AutomationProperties.Name="{DynamicResource presets.target}" /></StackPanel>- <Grid ColumnDefinitions="*,12,*">+ <Grid ColumnDefinitions="3*,12,2*"><StackPanel><TextBlock Classes="label" Text="{DynamicResource presets.resize}" /><ComboBox x:Name="ResizeChoice" ItemsSource="{Binding ResizeModes}" SelectedItem="{Binding Resize}" HorizontalAlignment="Stretch"@@ -48,10 +48,15 @@<NumericUpDown Value="{Binding Width}" Minimum="16" Maximum="20000" Increment="100" FormatString="0" AutomationProperties.Name="{DynamicResource presets.width}" /></StackPanel></Grid>- <TextBlock x:Name="SizeChange" Classes="caption" Text="{Binding SizeChange}"- IsVisible="{Binding SizeChange, Converter={x:Static StringConverters.IsNotNullOrEmpty}}" />+ <!-- The first picture's size before and after. Each size stays "width × height" in Arabic too; the arrow and their+ order follow the reading direction. -->+ <StackPanel x:Name="SizeChange" Orientation="Horizontal" Spacing="6" IsVisible="{Binding ShowSize}">+ <TextBlock Classes="caption" Text="{Binding SizeBefore}" FlowDirection="LeftToRight" />+ <TextBlock Classes="caption" Text="{DynamicResource AppForwardArrow}" />+ <TextBlock Classes="caption" Text="{Binding SizeAfter}" FlowDirection="LeftToRight" FontWeight="SemiBold" />+ </StackPanel>- <Grid ColumnDefinitions="*,12,*">+ <Grid ColumnDefinitions="3*,12,2*"><StackPanel><TextBlock Classes="label" Text="{DynamicResource presets.rotation}" /><ComboBox ItemsSource="{Binding Rotations}" SelectedItem="{Binding Rotation}" HorizontalAlignment="Stretch"diff --git a/src/Filee.App/Views/ImageEditWindow.axaml.cs b/src/Filee.App/Views/ImageEditWindow.axaml.csindex db43f634..cd5a3d75 100644--- a/src/Filee.App/Views/ImageEditWindow.axaml.cs+++ b/src/Filee.App/Views/ImageEditWindow.axaml.cs@@ -1,5 +1,9 @@+using Avalonia;using Avalonia.Controls;+using Avalonia.Controls.Primitives;+using Avalonia.Input;using Avalonia.Interactivity;+using Avalonia.VisualTree;using Filee.App.Services;using Filee.App.ViewModels;@@ -12,9 +16,32 @@ public partial class ImageEditWindow : WindowInitializeComponent();Motion.Track(this);UiZoom.Track(this);+ AddHandler(KeyDownEvent, OnKeyDownFirst, RoutingStrategies.Tunnel);+ // The format first, so the keys work at once; Tab goes on down the window.+ Opened += (_, _) => TargetChoice.Focus();}- private void OnConvert(object? sender, RoutedEventArgs e)+ /// <summary>+ /// Before any focused control: Enter converts, as in the crop window, also on a closed list (which would open) or the+ /// grayscale box (which would tick). An open list keeps Enter to pick, a number being typed takes it first so it+ /// counts (then the Convert button converts), and the Cancel and Convert buttons keep their own.+ /// </summary>+ private void OnKeyDownFirst(object? sender, KeyEventArgs e)+ {+ if (e.Key != Key.Enter || e.KeyModifiers != KeyModifiers.None)+ return;+ var source = e.Source as Visual;+ if (source?.FindAncestorOfType<NumericUpDown>(includeSelf: true) is not null+ || source is Button and not ToggleButton+ || this.GetVisualDescendants().OfType<ComboBox>().Any(list => list.IsDropDownOpen))+ return;+ Convert();+ e.Handled = true;+ }++ private void OnConvert(object? sender, RoutedEventArgs e) => Convert();++ private void Convert(){if (DataContext is not ImageEditViewModel vm || vm.Pictures.Count == 0) return;vm.Convert();diff --git a/src/Filee.Core/Presets/ImageEditTool.cs b/src/Filee.Core/Presets/ImageEditTool.csindex 82fb19ba..5814b8dc 100644--- a/src/Filee.Core/Presets/ImageEditTool.cs+++ b/src/Filee.Core/Presets/ImageEditTool.cs@@ -19,10 +19,26 @@ public static class ImageEditTool/// <summary>Formats the quality slider is shown for.</summary>public static readonly IReadOnlySet<string> LossyTargets = new HashSet<string> { "jpg", "webp", "avif", "heic" };+ /// <summary>+ /// The resizes the window offers, named rather than every <see cref="ResizeMode"/>: a mode added later (a free+ /// width × height, #593) needs fields of its own in the window before it can be offered there.+ /// </summary>+ public static readonly IReadOnlyList<ResizeMode> ResizeModes = [ResizeMode.None, ResizeMode.Percent, ResizeMode.LongEdge, ResizeMode.Width];+/// <summary>True when a <paramref name="sourceFormat"/> file is a picture the tool can open.</summary>public static bool CanEdit(string sourceFormat) =>FormatRegistry.FindById(sourceFormat)?.Category == FormatCategory.Image;+ /// <summary>+ /// The <see cref="Targets"/> at least one of the <paramref name="sourceFormats"/> can be written in with the engines+ /// there are: HEIC only once FFmpeg is downloaded, as the donut's HEIC preset.+ /// </summary>+ public static IReadOnlyList<string> TargetsFrom(IEnumerable<string> sourceFormats, RoutePlanner planner)+ {+ var sources = sourceFormats.Distinct().ToList();+ return [.. Targets.Where(target => sources.Any(source => planner.Plan(source, target) is not null))];+ }+/// <summary>/// The format a <paramref name="sourceFormat"/> picture is written in for the <paramref name="chosen"/> one: as/// chosen, but for "Same format as the source" one that can't be written straight from it becomesdiff --git a/src/Filee.Core/Settings/UserDataStore.cs b/src/Filee.Core/Settings/UserDataStore.csindex fdfdd4cd..a9462d5f 100644--- a/src/Filee.Core/Settings/UserDataStore.cs+++ b/src/Filee.Core/Settings/UserDataStore.cs@@ -891,8 +891,9 @@ internal static class SettingsMigrationschanged |= LearnExtensions(profiles, out _, ["m4s"]);// v49: "Edit pictures" (size, format, turn and colour chosen each time, #584), after "Crop" as in a new library,// and on the front of the images donut after "Half size" when that is there, the user hasn't put the tool- // elsewhere on the donut and the face has room. Present already but saved since by a Filee before 49: that one dropped the tool's- // name, which made it a crop, so it is put back.+ // elsewhere on the donut and the face has room.+ // Present already but saved since by a Filee before 45 (2.0): that one dropped the tool's name, which made it+ // a crop, so it is put back. 2.1 keeps the name (the slice is greyed out there, as a tool it doesn't know).if (from < 49)changed |= AddImageEditTool(presets, profiles);return changed;diff --git a/src/Filee.Engines/Magick/ImageEncoder.cs b/src/Filee.Engines/Magick/ImageEncoder.csindex 1296655a..78ef5582 100644--- a/src/Filee.Engines/Magick/ImageEncoder.cs+++ b/src/Filee.Engines/Magick/ImageEncoder.cs@@ -485,6 +485,10 @@ internal static class ImageEncodervar sizes = options.IcoSizes.Where(s => s is > 0 and <= 256).Distinct().OrderDescending().ToList();if (sizes.Count == 0)sizes = [256, 48, 32, 16];+ // Resized on purpose to less than an icon holds ("Edit pictures": 512 × 512 → 32 × 32): the icon is that size and+ // the smaller ones asked for, not the larger sizes blown up from it.+ if (options.Resize != ResizeMode.None && side < 256)+ sizes = [(int)side, .. sizes.Where(s => s < side)];image.Settings.SetDefine(MagickFormat.Icon, "auto-resize", string.Join(',', sizes));}diff --git a/tests/Filee.App.Tests/ImageEditWindowTests.cs b/tests/Filee.App.Tests/ImageEditWindowTests.csindex 906c981c..fe6456c0 100644--- a/tests/Filee.App.Tests/ImageEditWindowTests.cs+++ b/tests/Filee.App.Tests/ImageEditWindowTests.cs@@ -1,8 +1,14 @@// The "Edit pictures" window (#584): it opens with the tool's last choices, shows the first picture's size before and-// after, starts one conversion per format the pictures are written in, and keeps the choices in the tool.+// after, starts one conversion per format the pictures are written in, and keeps the choices in the tool. Enter+// converts and Escape closes; screenshots in light and dark, short and long languages, right to left.using System.IO;+using Avalonia.Controls;+using Avalonia.Headless;using Avalonia.Headless.XUnit;+using Avalonia.Input;+using Avalonia.Threading;+using Avalonia.VisualTree;using Filee.App.Services;using Filee.App.ViewModels;using Filee.App.Views;@@ -16,24 +22,45 @@ namespace Filee.App.Tests;public class ImageEditWindowTests{+ public static TheoryData<string, bool> Looks => new()+ {+ { "en", false }, { "en", true }, { "ko", false }, { "ko", true }, { "ar", false }, { "ar", true },+ // Long names of the resizes and flips: "Ограничить длинную сторону", "लामो छेउ सीमित गर्नुहोस्", "แนวนอน (ซ้าย-ขวา)".+ { "de", false }, { "ru", false }, { "ru", true }, { "ne", false }, { "hi", true }, { "th", false },+ };++ [AvaloniaTheory]+ [MemberData(nameof(Looks))]+ public void The_window_renders(string language, bool dark)+ {+ WithWindow(["holiday-photo-from-the-harbour.jpg", "b.png", "c.png"], (window, vm, _) =>+ {+ vm.Resize = vm.ResizeModes.Single(r => r.Value == ResizeMode.LongEdge);+ vm.LongEdge = 128;+ vm.Rotation = vm.Rotations.Single(r => r.Value == ImageRotation.Right90);+ Pump();+ Assert.True(vm.ShowQuality); // the JPG keeps its format+ Save(window, $"window-image-edit-{language}-{(dark ? "dark" : "light")}.png");+ }, language: language, dark: dark);+ }+[AvaloniaFact]public void The_window_shows_the_size_a_picture_gets_and_converts_with_the_choices(){- WithWindow(["icon.png", "scan.dcm"], (window, vm, starts) =>+ WithWindow(["icon.png", "scan.dcm"], (_, vm, starts) =>{Assert.Equal(AppHost.Get<ILocalizer>().Format("image_edit.count", 2), vm.Heading);Assert.Equal(BuiltInData.SameAsSource, vm.Target.Value);- Assert.Equal("512 × 256 → 512 × 256", vm.SizeChange);+ Assert.True(vm.ShowSize);+ Assert.Equal(("512 × 256", "512 × 256"), (vm.SizeBefore, vm.SizeAfter));vm.Resize = vm.ResizeModes.Single(r => r.Value == ResizeMode.LongEdge);vm.LongEdge = 32;Assert.True(vm.ShowLongEdge);- Assert.Equal("512 × 256 → 32 × 16", vm.SizeChange);+ Assert.Equal("32 × 16", vm.SizeAfter);vm.Rotation = vm.Rotations.Single(r => r.Value == ImageRotation.Right90);- Assert.Equal("512 × 256 → 16 × 32", vm.SizeChange);+ Assert.Equal("16 × 32", vm.SizeAfter);vm.Grayscale = true;- Pump();- Save(window, "window-image-edit-en.png");vm.Convert();@@ -52,16 +79,92 @@ public class ImageEditWindowTests}[AvaloniaFact]- public void The_quality_is_offered_for_lossy_formats_only()+ public void The_size_after_is_worked_out_as_the_encoder_does()+ {+ WithWindow(["icon.png"], (_, vm, _) =>+ {+ // Turned first, then resized: 512 × 256 turned is 256 × 512, and 128 wide is 128 × 256 (not 64 × 128).+ vm.Rotation = vm.Rotations.Single(r => r.Value == ImageRotation.Left90);+ vm.Resize = vm.ResizeModes.Single(r => r.Value == ResizeMode.Width);+ vm.Width = 128;+ Assert.Equal("128 × 256", vm.SizeAfter);++ // An icon is square and at most 256 px.+ vm.Rotation = vm.Rotations.Single(r => r.Value == ImageRotation.None);+ vm.Target = vm.Targets.Single(t => t.Value == "ico");+ vm.Resize = vm.ResizeModes.Single(r => r.Value == ResizeMode.LongEdge);+ vm.LongEdge = 32;+ Assert.Equal("32 × 32", vm.SizeAfter);+ vm.Resize = vm.ResizeModes.Single(r => r.Value == ResizeMode.None);+ Assert.Equal("256 × 256", vm.SizeAfter);+ });+ }++ [AvaloniaFact]+ public void The_window_offers_the_resizes_it_has_fields_for()+ {+ // A resize mode added later (#593's free width × height) needs its fields here before it is offered.+ WithWindow(["icon.png"], (_, vm, _) =>+ Assert.Equal([ResizeMode.None, ResizeMode.Percent, ResizeMode.LongEdge, ResizeMode.Width], vm.ResizeModes.Select(r => r.Value)));+ }++ [AvaloniaFact]+ public void The_quality_is_offered_where_a_picture_is_written_lossy(){WithWindow(["icon.png"], (_, vm, _) =>{Assert.Equal("icon.png", vm.Heading);+ Assert.Equal(BuiltInData.SameAsSource, vm.Target.Value);+ Assert.False(vm.ShowQuality); // a PNG kept a PNG has no qualityvm.Target = vm.Targets.Single(t => t.Value == "jpg");Assert.True(vm.ShowQuality);vm.Target = vm.Targets.Single(t => t.Value == "ico");Assert.False(vm.ShowQuality);});+ WithWindow(["icon.png", "photo.jpg"], (_, vm, _) => Assert.True(vm.ShowQuality));+ }++ [AvaloniaFact]+ public void Enter_converts_from_a_list_and_escape_closes()+ {+ WithWindow(["icon.png"], (window, _, starts) =>+ {+ // The format list has the focus when the window opens; Enter there converts instead of opening it.+ Assert.IsType<ComboBox>(window.FocusManager?.GetFocusedElement());+ Press(window, Key.Enter);+ Assert.Single(starts);+ Assert.False(window.IsVisible);+ });+ WithWindow(["icon.png"], (window, _, starts) =>+ {+ var grayscale = window.GetVisualDescendants().OfType<CheckBox>().Single();+ grayscale.Focus();+ Press(window, Key.Enter);+ Assert.Single(starts);+ Assert.False(grayscale.IsChecked);+ });+ WithWindow(["icon.png"], (window, _, starts) =>+ {+ Press(window, Key.Escape);+ Assert.Empty(starts);+ Assert.False(window.IsVisible);+ });+ }++ [AvaloniaFact]+ public void Arabic_keeps_each_size_left_to_right_and_points_the_arrow_its_way()+ {+ WithWindow(["icon.png"], (window, vm, _) =>+ {+ vm.Resize = vm.ResizeModes.Single(r => r.Value == ResizeMode.LongEdge);+ vm.LongEdge = 32;+ Pump();+ var line = window.FindControl<StackPanel>("SizeChange")!;+ var texts = line.Children.OfType<TextBlock>().ToList();+ Assert.Equal(["512 × 256", "←", "32 × 16"], texts.Select(t => t.Text));+ Assert.Equal(Avalonia.Media.FlowDirection.RightToLeft, line.FlowDirection);+ Assert.All([texts[0], texts[2]], t => Assert.Equal(Avalonia.Media.FlowDirection.LeftToRight, t.FlowDirection));+ }, language: "ar");}[AvaloniaFact]@@ -98,10 +201,48 @@ public class ImageEditWindowTests}}+ [AvaloniaFact]+ public void The_size_read_is_the_one_seen_and_an_icons_largest()+ {+ var folder = Directory.CreateTempSubdirectory("filee-image-edit-size-").FullName;+ try+ {+ // A phone photo stored on its side, upright by its EXIF orientation.+ var photo = Path.Combine(folder, "phone.jpg");+ using (var image = new MagickImage(MagickColors.SkyBlue, 400, 300))+ {+ var exif = new ExifProfile();+ exif.SetValue(ExifTag.Orientation, (ushort)6); // "turn right to view"+ image.SetProfile(exif);+ image.Orientation = OrientationType.RightTop;+ image.Write(photo, MagickFormat.Jpg);+ }+ Assert.Equal((300, 400), WindowService.PictureSize(photo));++ var icon = Path.Combine(folder, "app.ico");+ using (var image = new MagickImage(MagickColors.Coral, 64, 64))+ {+ image.Settings.SetDefine(MagickFormat.Icon, "auto-resize", "16,64,32");+ image.Write(icon, MagickFormat.Icon);+ }+ Assert.Equal((64, 64), WindowService.PictureSize(icon));++ File.WriteAllBytes(Path.Combine(folder, "broken.png"), [0]);+ Assert.Null(WindowService.PictureSize(Path.Combine(folder, "broken.png")));+ }+ finally+ {+ try { Directory.Delete(folder, true); } catch (IOException) { }+ }+ }+private static void WithWindow(string[] names, Action<ImageEditWindow, ImageEditViewModel, List<(IReadOnlyList<string> Paths, Preset Preset)>> act,- Preset? tool = null)+ Preset? tool = null, string language = "en", bool dark = false){- TestServices.EnsureInitialized("en");+ TestServices.EnsureInitialized(language);+ var theme = AppHost.Get<ThemeService>();+ if (dark)+ theme.Apply(new ThemeSettings { Mode = ThemeMode.Dark }, language);var folder = Directory.CreateTempSubdirectory("filee-image-edit-").FullName;ImageEditWindow? window = null;try@@ -109,34 +250,34 @@ public class ImageEditWindowTestsvar files = names.Select(name => Path.Combine(folder, name)).ToList();foreach (var file in files)File.WriteAllBytes(file, [0]);- using (var picture = new MagickImage(MagickColors.SkyBlue, 512, 256))- picture.Write(files[0], MagickFormat.Png);+ foreach (var picture in files.Where(f => Path.GetExtension(f) is ".png" or ".jpg").Take(2))+ {+ using var image = new MagickImage(MagickColors.SkyBlue, 512, 256);+ image.Write(picture);+ }var starts = new List<(IReadOnlyList<string>, Preset)>();tool ??= BuiltInData.ImageEditPresets().Single();var vm = new ImageEditViewModel(files, tool, AppHost.Get<ILocalizer>(), AppHost.Get<UserDataStore>(),(path, chosen) => chosen == BuiltInData.SameAsSource && path.EndsWith(".dcm", StringComparison.Ordinal) ? "png" : chosen,- (paths, preset) => starts.Add((paths, preset)),- path =>- {- try- {- var info = new MagickImageInfo(path);- return ((int)info.Width, (int)info.Height);- }- catch (MagickException)- {- return null;- }- });+ (paths, preset) => starts.Add((paths, preset)), WindowService.PictureSize);window = new ImageEditWindow { DataContext = vm };window.Show();+ Pump();act(window, vm, starts);}finally{if (window?.IsVisible == true)window.Close();+ if (dark)+ theme.Apply(new ThemeSettings(), language);try { Directory.Delete(folder, true); } catch (IOException) { }}}++ private static void Press(ImageEditWindow window, Key key)+ {+ window.KeyPress(key, RawInputModifiers.None, PhysicalKey.None, null);+ Dispatcher.UIThread.RunJobs();+ }}diff --git a/tests/Filee.Core.Tests/ImageEditToolTests.cs b/tests/Filee.Core.Tests/ImageEditToolTests.csindex 8c59c17b..f13526b6 100644--- a/tests/Filee.Core.Tests/ImageEditToolTests.cs+++ b/tests/Filee.Core.Tests/ImageEditToolTests.cs@@ -84,6 +84,19 @@ public class ImageEditToolTestsAssert.False(ImageEditTool.CanEdit("pdf"));}+ [Fact]+ public void The_formats_offered_are_those_a_picture_can_be_written_in()+ {+ // HEIC is written with the FFmpeg download: without it, not offered.+ var magick = new FakeConverter("magick", new ConversionEdge("png", "jpg"), new ConversionEdge("png", "webp"),+ new ConversionEdge("dcm", "png"), new ConversionEdge("jpg", "ico"));+ var planner = new ConverterCatalog([magick]).CreatePlanner();++ Assert.Equal(["png", "jpg", "webp", "ico"], ImageEditTool.TargetsFrom(["png", "dcm", "jpg"], planner));+ Assert.Equal(["ico"], ImageEditTool.TargetsFrom(["jpg"], planner));+ Assert.DoesNotContain("heic", ImageEditTool.TargetsFrom(["png"], planner));+ }+// ───────────────────────── Settings schema 49 ─────────────────────────[Fact]@@ -142,7 +155,7 @@ public class ImageEditToolTests[Fact]public void Back_from_an_older_Filee_the_tool_edits_pictures_again_and_keeps_the_users_changes(){- // A Filee before 49 reads the unknown "tool" as nothing (a crop) and saves it so.+ // A Filee before 45 (2.0) has no "tool": it reads the tool as a crop and saves it so.var presets = BuiltInData.CreatePresets();var edit = presets.Single(p => p.Id == "tool-image-edit");edit.Tool = null;diff --git a/tests/Filee.Engines.Tests/ImageAndPdfTests.cs b/tests/Filee.Engines.Tests/ImageAndPdfTests.csindex 052f1607..21b674ca 100644--- a/tests/Filee.Engines.Tests/ImageAndPdfTests.cs+++ b/tests/Filee.Engines.Tests/ImageAndPdfTests.cs@@ -195,6 +195,20 @@ public class ImageAndPdfTests(EngineFixture fx) : IClassFixture<EngineFixture>Assert.Equal([64u, 32u, 16u], icons.Select(i => i.Width));}+ [Fact]+ public async Task Ico_resized_below_its_sizes_holds_that_size_and_the_smaller_ones()+ {+ // "Edit pictures" (#584): 512 × 512 → long edge 32 is a 32 px icon, not 256 and 48 blown up from 32 px.+ var dir = fx.NewFolder();+ var source = EngineFixture.MakeImage(dir, "logo.png", MagickFormat.Png, 512, 512);++ var job = await fx.ConvertAsync([source], new Preset { TargetFormat = "ico", Image = { Resize = ResizeMode.LongEdge, LongEdge = 32 } });++ AssertDone(job);+ using var icons = new MagickImageCollection(job.Outputs.Single());+ Assert.Equal([32u, 16u], icons.Select(i => i.Width));+ }+[Fact]public async Task Multi_page_tiff_to_png_writes_one_file_per_page(){