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
Review of #351: no trim for formats without transparency, plain comment, docs, all 12 languages
cre8ive-marketinga2a8897af213
diff --git a/docs/ENGINES.md b/docs/ENGINES.mdindex 3ba038b0..cc0f7838 100644--- a/docs/ENGINES.md+++ b/docs/ENGINES.md@@ -143,6 +143,13 @@ pinned source in `build/build-linux-native.py` like rhwp (PR #113 did this for S## Images and vector graphics+- **Trim transparent borders** (preset *Trim transparent borders*, `ImageOptions.TrimTransparent`, #332) crops a PNG,+ WebP, … to the box around its pixels that aren't fully transparent (`ImageEncoder.TrimTransparentBorders`) and saves+ `name_trimmed` in the same format; the source is never overwritten. Only alpha counts: ImageMagick's own trim+ takes the corners' colour, so content touching a corner would lose a solid border. Pictures without transparent+ borders, fully transparent ones and multi-frame animations (each frame alone would shift) come out as they are.+ Formats that can't be transparent (JPG, HEIC, …) have nothing to trim: the preset is greyed out for them, and a+ JPG in a mixed selection fails with that reason instead of being re-encoded.- **Animations.** An animated GIF, WebP, APNG or MNG keeps every frame and its timing when converted to one of these(animated GIF ↔ animated WebP ↔ APNG ↔ MNG, WebP lossy or lossless as the preset says) and becomes a multi-page TIFF;other targets get the first frame. Multi-page TIFFs and PDFs stay one image per page in WebP.@@ -759,6 +766,7 @@ options: the output is always pretty-printed.| Format | Library | Read | Written / lost ||---|---|---|---|| JSON (`.json`) | System.Text.Json | comments and trailing commas allowed (JSONC) | non-ASCII text as it is; NaN / infinities as text ("NaN") |+| HAR (`.har`, read only, #328) | System.Text.Json (`Data/HarData.cs`) | the HTTP Archive a browser's developer tools save: as JSON for JSON, YAML, TOML, XML and JSON Lines; as a table for CSV (and spreadsheets, Markdown, PDF through it), one row per request of `log.entries`: started, method, URL, status, time (ms), size (bytes), type. Pages, timings and headers stay in the JSON. A file without `log.entries` fails as no HAR | — (not written) || JSON Lines (`.jsonl`, `.ndjson`) | System.Text.Json | one value per line, blank lines skipped, read as an array | one compact line per record (the array, or the array inside wrappers, see CSV) || YAML (`.yaml`, `.yml`) | YamlDotNet (MIT) | YAML 1.2 core schema: unquoted `true`, `null` / `~`, numbers (`0x`, `0o`, `.inf`, `.nan`) are typed, the rest and anything quoted is text (`yes` / `no` stay text); explicit `!!str` / `!!int` … tags; anchors and aliases resolved (copied), merge keys (`<<`) applied; several documents (`---`) become an array; comments dropped; alias "bombs" (more than 5 million values) and nesting deeper than 256 refused | block style; text that would read back as another type (`"true"`, `"007"`, `""`, YAML 1.1's `yes` / `on`, dates) is quoted; multi-line text as a literal block (`\|`) || TOML (`.toml`) | Tomlyn (BSD-2-Clause, TOML 1.1) | dates and times keep their TOML spelling (text in JSON / YAML) | written by Filee: plain keys, then `[tables]` and `[[arrays of tables]]`; **null values are left out** (TOML has none); a root that is not an object goes under `items` (`[[items]]`); integers beyond 64 bits as text |@@ -1236,6 +1244,11 @@ Filee (with the GPL source offer), then an `engines.json` component and an optioframe or a folder of every frame, to every audio format (the sound track) and to SRT, ASS and WebVTT (the subtitles);every audio format to every audio format; and GIF, APNG and PNG to MP4, WEBM and MOV.Same-format edges exist too, so "MP4 720p" works on MP4 files and "MP3 128k" on MP3 files.+Raw H.265 and H.264 camera streams (`.h265`, `.265`, `.hevc`, `.h264`, `.264`, read only, #301) are Annex B elementary+streams without a container: FFmpeg reports them as format `hevc` / `h264` (`MediaInfo.RawStream`). They are always+encoded, never copied, because their frames carry no timestamps (a copy into MP4 had non-monotonic DTS). A stream+without timing information is read at FFmpeg's default 25 fps, so a camera that recorded at another rate plays faster+or slower; its frames are all kept.A Video CD's `MPEGAV/AVSEQ01.DAT` (MPEG-1 in a RIFF/CDXA wrapper) counts as MPEG: `.dat` is an extension of thatformat, and FFmpeg reads what the file holds, so a `.dat` with no video in it fails instead of making a file.diff --git a/src/Filee.App/Assets/i18n/ar.json b/src/Filee.App/Assets/i18n/ar.jsonindex 105438aa..92075075 100644--- a/src/Filee.App/Assets/i18n/ar.json+++ b/src/Filee.App/Assets/i18n/ar.json@@ -75,6 +75,7 @@"format_request.notice_text": "أخبرنا بالصيغة التي تحتاجها.\nتساعد الطلبات في تحديد الصيغ التي سيدعمها Filee لاحقًا.\nلا يمكن تحويل الملفات المشفّرة أو المحمية من النسخ (DRM)، مهما كانت صيغتها.","error.no_route": "لا يوجد محرك يستطيع إجراء هذا التحويل","error.cannot_turn": "التدوير والانعكاس متاحان للصور فقط",+ "error.no_transparency": "هذا التنسيق لا يدعم الشفافية، لذا لا يوجد ما يُقص","error.too_many_frames": "عدد الإطارات كبير جدًا لحفظها كصور. زِد قيمة «كل إطار رقم N»","error.not_enough_space": "لا توجد مساحة كافية على القرص لحفظ الصور","error.no_motion_photo": "لا تحتوي هذه الصورة على فيديو يستطيع Filee قراءته (صورة Motion Photo من Android، أو Live Photo من iPhone مع ملف MOV بجانبها)",diff --git a/src/Filee.App/Assets/i18n/en.json b/src/Filee.App/Assets/i18n/en.jsonindex 527d61b3..de204cd1 100644--- a/src/Filee.App/Assets/i18n/en.json+++ b/src/Filee.App/Assets/i18n/en.json@@ -81,6 +81,7 @@"format_request.notice_text": "Tell us which format you need.\nRequests decide what Filee supports next.\nEncrypted or copy-protected (DRM) files can't be converted, whatever the format.","error.no_route": "No engine can do this conversion","error.cannot_turn": "Rotate and flip work on images only",+ "error.no_transparency": "This format has no transparency, so there's nothing to trim","error.too_many_frames": "Too many frames to save as pictures, raise \"Every Nth frame\"","error.not_enough_space": "Not enough free disk space for the pictures","error.no_motion_photo": "This photo has no video Filee can read (an Android Motion Photo, or an iPhone Live Photo with its MOV next to it)",diff --git a/src/Filee.App/Assets/i18n/es.json b/src/Filee.App/Assets/i18n/es.jsonindex 12c29b7e..d68b6008 100644--- a/src/Filee.App/Assets/i18n/es.json+++ b/src/Filee.App/Assets/i18n/es.json@@ -75,6 +75,7 @@"format_request.notice_text": "Cuéntanos qué formato necesitas.\nLas solicitudes determinan qué formatos admitirá Filee a continuación.\nLos archivos cifrados o con protección de copia (DRM) no se pueden convertir, sea cual sea su formato.","error.no_route": "Ningún motor puede hacer esta conversión","error.cannot_turn": "Rotar y voltear solo funcionan con imágenes",+ "error.no_transparency": "Este formato no tiene transparencia, así que no hay nada que recortar","error.too_many_frames": "Demasiados fotogramas para guardar como imágenes; aumenta «Cada N fotogramas»","error.not_enough_space": "Espacio libre en disco insuficiente para las imágenes","error.no_motion_photo": "Esta foto no tiene un vídeo que Filee pueda leer (una Motion Photo de Android o una Live Photo de iPhone con su MOV al lado)",diff --git a/src/Filee.App/Assets/i18n/fr.json b/src/Filee.App/Assets/i18n/fr.jsonindex 32197851..363dbd8d 100644--- a/src/Filee.App/Assets/i18n/fr.json+++ b/src/Filee.App/Assets/i18n/fr.json@@ -81,6 +81,7 @@"format_request.notice_text": "Dites-nous de quel format vous avez besoin.\nLes demandes décident de ce que Filee prendra en charge ensuite.\nLes fichiers chiffrés ou protégés contre la copie (DRM) ne peuvent pas être convertis, quel que soit le format.","error.no_route": "Aucun moteur ne peut effectuer cette conversion","error.cannot_turn": "La rotation et le retournement ne s'appliquent qu'aux images",+ "error.no_transparency": "Ce format n'a pas de transparence : il n'y a rien à rogner","error.too_many_frames": "Trop d'images à enregistrer, augmentez « Une image sur N »","error.not_enough_space": "Pas assez d'espace disque libre pour les images","error.no_motion_photo": "Cette photo ne contient aucune vidéo lisible par Filee (une Motion Photo Android, ou une Live Photo d'iPhone avec son MOV à côté)",@@ -193,6 +194,7 @@"preset.half_size": "Taille 50 %","preset.grayscale": "Niveaux de gris","preset.remove_background": "Détourer",+ "preset.trim_transparent": "Rogner les bords transparents","preset.group_rotate": "Rotation","preset.rotate_left": "Pivoter à gauche","preset.rotate_left.short": "Gauche",diff --git a/src/Filee.App/Assets/i18n/hi.json b/src/Filee.App/Assets/i18n/hi.jsonindex aa618b6d..2cc7e288 100644--- a/src/Filee.App/Assets/i18n/hi.json+++ b/src/Filee.App/Assets/i18n/hi.json@@ -75,6 +75,7 @@"format_request.notice_text": "हमें बताएँ कि आपको कौन-सा फ़ॉर्मैट चाहिए।\nअनुरोधों से तय होता है कि Filee आगे क्या समर्थन करेगा।\nएन्क्रिप्टेड या कॉपी-सुरक्षित (DRM) फ़ाइलें किसी भी फ़ॉर्मैट में कन्वर्ट नहीं की जा सकतीं।","error.no_route": "कोई भी इंजन यह कन्वर्ज़न नहीं कर सकता","error.cannot_turn": "घुमाना और पलटना केवल इमेज पर काम करता है",+ "error.no_transparency": "इस फ़ॉर्मैट में पारदर्शिता नहीं है, इसलिए काटने को कुछ नहीं है","error.too_many_frames": "तस्वीरों के रूप में सहेजने के लिए बहुत ज़्यादा फ़्रेम हैं, \"हर Nवाँ फ़्रेम\" बढ़ाएँ","error.not_enough_space": "तस्वीरों के लिए डिस्क पर पर्याप्त खाली जगह नहीं है","error.no_motion_photo": "इस फ़ोटो में ऐसा कोई वीडियो नहीं है जिसे Filee पढ़ सके (Android मोशन फ़ोटो, या पास में अपनी MOV फ़ाइल वाली iPhone लाइव फ़ोटो)",diff --git a/src/Filee.App/Assets/i18n/ja.json b/src/Filee.App/Assets/i18n/ja.jsonindex c4cc75d9..6d2b7afe 100644--- a/src/Filee.App/Assets/i18n/ja.json+++ b/src/Filee.App/Assets/i18n/ja.json@@ -75,6 +75,7 @@"format_request.notice_text": "必要な形式を教えてください。\nリクエストをもとに、今後Fileeが対応する形式を決めます。\n暗号化またはコピー保護(DRM)されたファイルは、形式にかかわらず変換できません。","error.no_route": "この変換に対応するエンジンがありません","error.cannot_turn": "回転と反転は画像でのみ使えます",+ "error.no_transparency": "この形式には透明部分がないため、切り取るものがありません","error.too_many_frames": "画像として保存するフレーム数が多すぎます。「Nフレームごと」の値を大きくしてください","error.not_enough_space": "画像を保存するための空き容量が不足しています","error.no_motion_photo": "この写真には、Fileeが読み取れる動画がありません(Androidのモーションフォト、または隣にMOVがあるiPhoneのLive Photo)",diff --git a/src/Filee.App/Assets/i18n/ko.json b/src/Filee.App/Assets/i18n/ko.jsonindex f72ac043..cde31179 100644--- a/src/Filee.App/Assets/i18n/ko.json+++ b/src/Filee.App/Assets/i18n/ko.json@@ -81,6 +81,7 @@"format_request.notice_text": "필요한 형식을 알려주세요.\n요청을 보고 다음에 지원할 형식을 정해요.\n암호화되거나 DRM이 걸린 파일은 변환할 수 없어요.","error.no_route": "이 변환을 할 수 있는 엔진이 없어요","error.cannot_turn": "회전·반전은 이미지에만 할 수 있어요",+ "error.no_transparency": "이 형식에는 투명한 부분이 없어서 잘라낼 것이 없어요","error.too_many_frames": "프레임이 너무 많아요. 'N번째 프레임마다' 값을 늘려 주세요","error.not_enough_space": "이미지를 저장할 디스크 공간이 부족해요","error.no_motion_photo": "이 사진에서 읽을 수 있는 동영상을 찾지 못했어요 (안드로이드 모션 포토, 또는 옆에 MOV가 있는 아이폰 라이브 포토)",diff --git a/src/Filee.App/Assets/i18n/pl.json b/src/Filee.App/Assets/i18n/pl.jsonindex 9f0aadfb..344afcbe 100644--- a/src/Filee.App/Assets/i18n/pl.json+++ b/src/Filee.App/Assets/i18n/pl.json@@ -81,6 +81,7 @@"format_request.notice_text": "Napisz, jakiego formatu potrzebujesz.\nNa podstawie próśb wybieramy kolejne obsługiwane formaty.\nPlików zaszyfrowanych lub chronionych przed kopiowaniem (DRM) nie da się konwertować, niezależnie od formatu.","error.no_route": "Żaden silnik nie wykona tej konwersji","error.cannot_turn": "Obracanie i odbicie działają tylko na obrazach",+ "error.no_transparency": "Ten format nie ma przezroczystości, więc nie ma czego przycinać","error.too_many_frames": "Za dużo klatek do zapisania jako obrazy, zwiększ „Co N-ta klatka”","error.not_enough_space": "Za mało wolnego miejsca na dysku na obrazy","error.no_motion_photo": "To zdjęcie nie ma wideo, które Filee może odczytać (Motion Photo z Androida lub Live Photo z iPhone'a z plikiem MOV obok)",diff --git a/src/Filee.App/Assets/i18n/pt-BR.json b/src/Filee.App/Assets/i18n/pt-BR.jsonindex 4d8dafe4..4d9a28f3 100644--- a/src/Filee.App/Assets/i18n/pt-BR.json+++ b/src/Filee.App/Assets/i18n/pt-BR.json@@ -81,6 +81,7 @@"format_request.notice_text": "Diga qual formato você precisa.\nOs pedidos decidem o que o Filee passa a aceitar.\nArquivos criptografados ou protegidos contra cópia (DRM) não podem ser convertidos, seja qual for o formato.","error.no_route": "Nenhum motor faz esta conversão","error.cannot_turn": "Girar e espelhar só funcionam em imagens",+ "error.no_transparency": "Este formato não tem transparência, então não há nada para cortar","error.too_many_frames": "Quadros demais para salvar como imagens. Aumente “A cada N quadros”","error.not_enough_space": "Não há espaço livre suficiente em disco para as imagens","error.no_motion_photo": "Esta foto não tem um vídeo que o Filee consiga ler (uma Motion Photo do Android, ou uma Live Photo do iPhone com o MOV ao lado)",diff --git a/src/Filee.App/Assets/i18n/ru.json b/src/Filee.App/Assets/i18n/ru.jsonindex ef2222e1..5089323b 100644--- a/src/Filee.App/Assets/i18n/ru.json+++ b/src/Filee.App/Assets/i18n/ru.json@@ -81,6 +81,7 @@"format_request.notice_text": "Напишите, какой формат вам нужен.\nОт запросов зависит, что Filee будет поддерживать дальше.\nЗашифрованные и защищённые от копирования (DRM) файлы сконвертировать нельзя, в каком бы формате они ни были.","error.no_route": "Нет движка для такой конвертации","error.cannot_turn": "Поворот и отражение работают только с изображениями",+ "error.no_transparency": "В этом формате нет прозрачности, обрезать нечего","error.too_many_frames": "Слишком много кадров для сохранения картинками — увеличьте «Каждый N-й кадр»","error.not_enough_space": "Не хватает места на диске для картинок","error.no_motion_photo": "В этом фото нет видео, которое Filee может прочитать (Motion Photo с Android или Live Photo с iPhone с файлом MOV рядом)",diff --git a/src/Filee.App/Assets/i18n/zh-CN.json b/src/Filee.App/Assets/i18n/zh-CN.jsonindex ca82ca6c..2250a377 100644--- a/src/Filee.App/Assets/i18n/zh-CN.json+++ b/src/Filee.App/Assets/i18n/zh-CN.json@@ -81,6 +81,7 @@"format_request.notice_text": "告诉我们你需要的格式。\n我们会根据请求决定接下来支持哪些格式。\n加密或有复制保护 (DRM) 的文件,无论什么格式都无法转换。","error.no_route": "没有引擎可以完成此转换","error.cannot_turn": "只能旋转和翻转图片",+ "error.no_transparency": "此格式没有透明部分,无需裁剪","error.too_many_frames": "帧数太多,请调大“每 N 帧”","error.not_enough_space": "磁盘空间不足,无法保存这些图片","error.no_motion_photo": "这张照片中没有可读取的视频(安卓动态照片,或旁边有 MOV 的 iPhone 实况照片)",diff --git a/src/Filee.App/Assets/i18n/zh-TW.json b/src/Filee.App/Assets/i18n/zh-TW.jsonindex d1a197a1..a8b6f8f6 100644--- a/src/Filee.App/Assets/i18n/zh-TW.json+++ b/src/Filee.App/Assets/i18n/zh-TW.json@@ -81,6 +81,7 @@"format_request.notice_text": "告訴我們你需要的格式。\n我們會根據請求決定接下來支援哪些格式。\n加密或有複製保護 (DRM) 的檔案,無論什麼格式都無法轉換。","error.no_route": "沒有引擎可以完成此轉換","error.cannot_turn": "只能旋轉和翻轉圖片",+ "error.no_transparency": "此格式沒有透明部分,無需裁切","error.too_many_frames": "影格數太多,請調大「每 N 個影格」","error.not_enough_space": "磁碟空間不足,無法儲存這些圖片","error.no_motion_photo": "這張照片中沒有可讀取的影片(Android 動態相片,或旁邊有 MOV 的 iPhone 原況照片)",@@ -193,6 +194,7 @@"preset.half_size": "縮小 50%","preset.grayscale": "灰階","preset.remove_background": "去除背景",+ "preset.trim_transparent": "裁掉透明邊框","preset.group_rotate": "旋轉","preset.rotate_left": "向左旋轉","preset.rotate_left.short": "向左",diff --git a/src/Filee.App/Services/PresetAvailability.cs b/src/Filee.App/Services/PresetAvailability.csindex 55ee80f6..bf1225c4 100644--- a/src/Filee.App/Services/PresetAvailability.cs+++ b/src/Filee.App/Services/PresetAvailability.cs@@ -106,6 +106,11 @@ public sealed class PresetAvailabilityif (formats.Count == 0)return new(PresetUse.Unusable, _loc["error.unsupported_source"]);+ // "Trim transparent borders" on JPG and other formats without transparency would only re-encode them.+ if (preset.Image.TrimTransparent+ && formats.All(f => !Filee.Engines.Magick.ImageEncoder.HoldsAlpha(preset.TargetFormat == BuiltInData.SameAsSource ? f.Id : preset.TargetFormat)))+ return new(PresetUse.Unusable, _loc["error.no_transparency"]);+var merge = preset.Pdf.MergeIntoSingle && preset.TargetFormat == "pdf";var turns = preset.Image.TurnsOrMirrors;string TargetFor(FileFormat f) => preset.TargetFormat == BuiltInData.SameAsSource ? f.Id : preset.TargetFormat;diff --git a/src/Filee.Engines/Magick/ImageEncoder.cs b/src/Filee.Engines/Magick/ImageEncoder.csindex 6d844214..3296b664 100644--- a/src/Filee.Engines/Magick/ImageEncoder.cs+++ b/src/Filee.Engines/Magick/ImageEncoder.cs@@ -67,6 +67,9 @@ internal static class ImageEncoder/// </summary>private static readonly HashSet<string> NoAlpha = ["jpg", "ppm", "heic", "xbm", "wbmp", "pfm", "pcx", "ras"];+ /// <summary>False for formats Filee writes without transparency (<see cref="NoAlpha"/>): nothing to trim there.</summary>+ public static bool HoldsAlpha(string format) => !NoAlpha.Contains(format);+/// <summary>/// Formats read with their ImageMagick coder named instead of guessed from the file: some extensions mean another/// format to ImageMagick (.rgb and .bw are headerless pixel data there, SGI here) and WBMP has no signature.diff --git a/src/Filee.Engines/Magick/MagickImageConverter.cs b/src/Filee.Engines/Magick/MagickImageConverter.csindex 48d2f20f..ebfe2972 100644--- a/src/Filee.Engines/Magick/MagickImageConverter.cs+++ b/src/Filee.Engines/Magick/MagickImageConverter.cs@@ -86,6 +86,10 @@ public sealed class MagickImageConverter : IConverter, ITiffMerger, IImageTransfcancellationToken.ThrowIfCancellationRequested();progress?.Report(0.3);+ // A JPG has no transparent border to trim: re-encoding it would only cost a JPEG generation.+ if (step.Preset.Image.TrimTransparent && !ImageEncoder.HoldsAlpha(step.To))+ throw new ConversionRefusedException("error.no_transparency", step.To.ToUpperInvariant());+var animation = ImageEncoder.KeepsAnimation(from, step.To);var frames = ImageEncoder.SelectFrames(images, from, step.To);// Before the options: frames dropped for speed aren't resized for nothing.@@ -95,7 +99,7 @@ public sealed class MagickImageConverter : IConverter, ITiffMerger, IImageTransf{cancellationToken.ThrowIfCancellationRequested();ImageEncoder.ApplyOptions(frame, step.Preset.Image, step.To);- // shortcut: animations aren't trimmed (each frame alone would shift), trim all frames to one box when asked.+ // Animations aren't trimmed: each frame trimmed alone would shift. Trimming all frames to one box could be added.if (step.Preset.Image.TrimTransparent && !(animation && frames.Count > 1))ImageEncoder.TrimTransparentBorders(frame);}diff --git a/tests/Filee.Engines.Tests/TrimTransparentTests.cs b/tests/Filee.Engines.Tests/TrimTransparentTests.csindex f264fe17..3f69dd82 100644--- a/tests/Filee.Engines.Tests/TrimTransparentTests.cs+++ b/tests/Filee.Engines.Tests/TrimTransparentTests.cs@@ -89,4 +89,21 @@ public class TrimTransparentTests(EngineFixture fx) : IClassFixture<EngineFixturFilee.Engines.Magick.ImageEncoder.TrimTransparentBorders(empty);Assert.Equal((40u, 30u), (empty.Width, empty.Height));}++ [Fact]+ public async Task A_jpg_has_nothing_to_trim_and_is_not_re_encoded()+ {+ var folder = fx.NewFolder();+ var photo = Path.Combine(folder, "photo.jpg");+ using (var image = new MagickImage(MagickColors.Teal, 60, 40))+ image.Write(photo, MagickFormat.Jpeg);++ var job = await fx.ConvertAsync([photo], Trim);++ Assert.Equal(JobState.Failed, job.State);+ Assert.Equal("error.no_transparency", job.Files[0].ErrorKey);+ Assert.Equal(["photo.jpg"], Directory.GetFiles(folder).Select(Path.GetFileName));+ Assert.False(Filee.Engines.Magick.ImageEncoder.HoldsAlpha("jpg"));+ Assert.True(Filee.Engines.Magick.ImageEncoder.HoldsAlpha("png"));+ }}