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
Merge branch 'main' into feature/video-frame-splitting
pleguen83c24626b6c6
diff --cc src/Filee.App/Assets/i18n/en.jsonindex 57bd4ab4,df514816..7fe4d5f6--- a/src/Filee.App/Assets/i18n/en.json+++ b/src/Filee.App/Assets/i18n/en.json@@@ -107,16 -130,9 +130,15 @@@"preset.long_image": "Long image","preset.extract": "Extract","preset.zip_all": "One ZIP",+ "preset.extract_subtitles": "Extract subtitles",+ "preset.trace_svg": "Trace to SVG",+ "preset.trace_line_art": "Line art to SVG",+ "preset.extract_frames_png": "Extract Frames (PNG)",+ "preset.extract_frames_png_hint": "Extracts every frame of the video into full-quality PNG images in a dedicated folder. Warning: can generate a large number of files on long videos.",+ "preset.extract_frames_png.description": "Extracts every frame of the video into full-quality PNG images in a dedicated folder. Warning: can generate a large number of files on long videos.",+ "preset.extract_frames_jpg": "Extract Frames (JPG)",+ "preset.extract_frames_jpg_hint": "Extracts every frame of the video into high-quality JPEG images in a dedicated folder. Warning: can generate a large number of files on long videos.",+ "preset.extract_frames_jpg.description": "Extracts every frame of the video into high-quality JPEG images in a dedicated folder. Warning: can generate a large number of files on long videos.",- "extract_frames_png": "Extract Frames (PNG)",- "extract_frames_png_hint": "Extracts every frame of the video into full-quality PNG images in a dedicated folder. Warning: can generate a large number of files on long videos.",- "extract_frames_jpg": "Extract Frames (JPG)",- "extract_frames_jpg_hint": "Extracts every frame of the video into high-quality JPEG images in a dedicated folder. Warning: can generate a large number of files on long videos.","format.folder": "Folder","format.category.Image": "Image",@@@ -304,10 -360,7 +366,10 @@@"presets.tiff_compression": "TIFF compression","presets.webp_lossless": "Lossless WEBP","presets.multipage_tiff": "Put every file into one multi-page TIFF",- "presets.multipage_tiff_hint": "Each image, each PDF page and each page of a TIFF becomes a page, in order. One PDF is enough for a multi-page TIFF.",+ "presets.multipage_tiff_hint": "Each image and each PDF or TIFF page becomes a page, in order.\nOne PDF is enough for a multi-page TIFF.",+ "presets.save_every_frame": "Save every frame as images",+ "presets.save_every_frame_hint": "When converting from video: extracts all frames to a dedicated subfolder instead of saving a single still frame.",+ "presets.frame_interval": "Every Nth frame","presets.ico_sizes": "Icon sizes","presets.group.pdf": "PDF","presets.merge": "Merge all files into one PDF",diff --cc src/Filee.App/Assets/i18n/ko.jsonindex 97b48c63,911d0f3b..a573ba06--- a/src/Filee.App/Assets/i18n/ko.json+++ b/src/Filee.App/Assets/i18n/ko.json@@@ -107,16 -130,9 +130,15 @@@"preset.long_image": "긴 이미지","preset.extract": "압축 풀기","preset.zip_all": "ZIP 하나로",+ "preset.extract_subtitles": "자막 추출",+ "preset.trace_svg": "벡터화",+ "preset.trace_line_art": "흑백 선화",+ "preset.extract_frames_png": "모든 프레임 추출 (PNG)",+ "preset.extract_frames_png_hint": "동영상의 모든 프레임을 전용 폴더에 원본 화질의 PNG 이미지로 추출합니다. 주의: 긴 동영상의 경우 많은 파일이 생성될 수 있습니다.",+ "preset.extract_frames_png.description": "동영상의 모든 프레임을 전용 폴더에 원본 화질의 PNG 이미지로 추출합니다. 주의: 긴 동영상의 경우 많은 파일이 생성될 수 있습니다.",+ "preset.extract_frames_jpg": "모든 프레임 추출 (JPG)",+ "preset.extract_frames_jpg_hint": "동영상의 모든 프레임을 전용 폴더에 고화질 JPG 이미지로 추출합니다. 주의: 긴 동영상의 경우 많은 파일이 생성될 수 있습니다.",+ "preset.extract_frames_jpg.description": "동영상의 모든 프레임을 전용 폴더에 고화질 JPG 이미지로 추출합니다. 주의: 긴 동영상의 경우 많은 파일이 생성될 수 있습니다.",- "extract_frames_png": "모든 프레임 추출 (PNG)",- "extract_frames_png_hint": "동영상의 모든 프레임을 전용 폴더에 원본 화질의 PNG 이미지로 추출합니다. 주의: 긴 동영상의 경우 많은 파일이 생성될 수 있습니다.",- "extract_frames_jpg": "모든 프레임 추출 (JPG)",- "extract_frames_jpg_hint": "동영상의 모든 프레임을 전용 폴더에 고화질 JPG 이미지로 추출합니다. 주의: 긴 동영상의 경우 많은 파일이 생성될 수 있습니다.","format.folder": "폴더","format.category.Image": "이미지",@@@ -304,10 -360,7 +366,10 @@@"presets.tiff_compression": "TIFF 압축","presets.webp_lossless": "무손실 WEBP","presets.multipage_tiff": "모든 파일을 여러 페이지짜리 TIFF 하나로 합치기",- "presets.multipage_tiff_hint": "이미지 한 장, PDF 한 페이지, TIFF의 각 페이지가 순서대로 한 페이지씩 들어가요. PDF 하나만 넣어도 여러 페이지 TIFF가 돼요.",+ "presets.multipage_tiff_hint": "이미지 한 장, PDF·TIFF 한 페이지가 순서대로 한 페이지씩 들어가요.\nPDF 하나만 넣어도 여러 페이지 TIFF가 돼요.",+ "presets.save_every_frame": "모든 프레임을 이미지로 저장",+ "presets.save_every_frame_hint": "동영상 변환 시: 단일 정지 이미지를 저장하는 대신 전용 하위 폴더에 모든 프레임을 추출합니다.",+ "presets.frame_interval": "N번째 프레임마다","presets.ico_sizes": "아이콘 크기","presets.group.pdf": "PDF","presets.merge": "모든 파일을 하나의 PDF로 합치기",diff --cc src/Filee.App/Assets/i18n/zh-CN.jsonindex 4fd34c6e,d6f4f5b8..9e48eeab--- a/src/Filee.App/Assets/i18n/zh-CN.json+++ b/src/Filee.App/Assets/i18n/zh-CN.json@@@ -107,16 -130,9 +130,15 @@@"preset.long_image": "长图","preset.extract": "解压","preset.zip_all": "打包成一个 ZIP",+ "preset.extract_subtitles": "提取字幕",+ "preset.trace_svg": "描摹",+ "preset.trace_line_art": "黑白描摹",+ "preset.extract_frames_png": "提取所有帧 (PNG)",+ "preset.extract_frames_png_hint": "将视频的每一帧提取为无损 PNG 图像并保存至专属文件夹。注意:长视频可能会生成大量图片文件。",+ "preset.extract_frames_png.description": "将视频的每一帧提取为无损 PNG 图像并保存至专属文件夹。注意:长视频可能会生成大量图片文件。",+ "preset.extract_frames_jpg": "提取所有帧 (JPG)",+ "preset.extract_frames_jpg_hint": "将视频的每一帧提取为高质量 JPG 图像并保存至专属文件夹。注意:长视频可能会生成大量图片文件。",+ "preset.extract_frames_jpg.description": "将视频的每一帧提取为高质量 JPG 图像并保存至专属文件夹。注意:长视频可能会生成大量图片文件。",- "extract_frames_png": "提取所有帧 (PNG)",- "extract_frames_png_hint": "将视频的每一帧提取为无损 PNG 图像并保存至专属文件夹。注意:长视频可能会生成大量图片文件。",- "extract_frames_jpg": "提取所有帧 (JPG)",- "extract_frames_jpg_hint": "将视频的每一帧提取为高质量 JPG 图像并保存至专属文件夹。注意:长视频可能会生成大量图片文件。","format.folder": "文件夹","format.category.Image": "图片",@@@ -304,10 -360,7 +366,10 @@@"presets.tiff_compression": "TIFF 压缩","presets.webp_lossless": "无损 WEBP","presets.multipage_tiff": "将所有文件合并为一个多页 TIFF",- "presets.multipage_tiff_hint": "每张图片、每个 PDF 页面以及 TIFF 的每一页都会按顺序成为一页。只放一个 PDF 也能得到多页 TIFF。",+ "presets.multipage_tiff_hint": "每张图片以及 PDF、TIFF 的每一页按顺序各成一页。\n只放一个 PDF 也能得到多页 TIFF。",+ "presets.save_every_frame": "将所有帧保存为图像",+ "presets.save_every_frame_hint": "从视频转换时:将所有帧提取到专用子文件夹中,而不是仅保存单张静态图像。",+ "presets.frame_interval": "每 N 帧","presets.ico_sizes": "图标尺寸","presets.group.pdf": "PDF","presets.merge": "将所有文件合并为一个 PDF",diff --cc src/Filee.App/ViewModels/PresetEditorViewModel.csindex 29fd16a0,45382072..2bfc828e--- a/src/Filee.App/ViewModels/PresetEditorViewModel.cs+++ b/src/Filee.App/ViewModels/PresetEditorViewModel.cs@@@ -87,10 -92,13 +92,15 @@@ public sealed partial class PresetEdito_audioChannels = AudioChannelChoices.FirstOrDefault(c => c.Value == _edit.Media.AudioChannels) ?? AudioChannelChoices[0];_sampleRate = SampleRates.First(r => r.Value == _edit.Media.AudioSampleRate);_wavFormat = WavFormats.First(f => f.Value == _edit.Media.WavFormat);+ _videoCodecValue = _edit.Media.VideoCodec;+ _audioCodecValue = _edit.Media.AudioCodec;_archiveLevel = ArchiveLevels.First(l => l.Value == _edit.Archive.Level);_combineIntoOne = _edit.Archive.CombineIntoOne;+ _saveEveryFrame = _edit.Media.SaveEveryFrame;+ _frameInterval = _edit.Media.FrameInterval > 0 ? _edit.Media.FrameInterval : 1;+ _traceMode = TraceModes.First(m => m.Value == _edit.Trace.Mode);+ _traceColors = Math.Clamp(_edit.Trace.Colors, TracingOptions.MinColors, TracingOptions.MaxColors);+ _traceDetail = Math.Clamp(_edit.Trace.Detail, 0, 100);_quality = _edit.Image.Quality;_resizePercent = _edit.Image.ResizePercent;_longEdge = _edit.Image.LongEdge;@@@ -139,14 -155,60 +157,61 @@@private string _name;[ObservableProperty]- [NotifyPropertyChangedFor(nameof(ShowImage), nameof(ShowQuality), nameof(ShowTiff), nameof(ShowMultiPageTiff), nameof(ShowWebp), nameof(ShowIco),+ [NotifyPropertyChangedFor(nameof(ShowImage), nameof(ShowTurnForPdf), nameof(ShowQuality), nameof(ShowTiff), nameof(ShowMultiPageTiff), nameof(ShowWebp), nameof(ShowIco),nameof(ShowPdf), nameof(ShowPdfBuild), nameof(ShowDocument), nameof(ShowPdfSplit), nameof(ShowPdfCombine),nameof(ShowMedia), nameof(ShowMediaQuality), nameof(ShowMaxHeight), nameof(ShowAudioBitrate), nameof(ShowRemoveAudio),- nameof(ShowAudioChannels), nameof(ShowWav),+ nameof(ShowAudioChannels), nameof(ShowWav), nameof(VideoCodecs), nameof(VideoCodecChoice), nameof(ShowVideoCodec),+ nameof(AudioCodecs), nameof(AudioCodecChoice), nameof(ShowAudioCodec),- nameof(ShowArchive), nameof(ShowArchiveOptions), nameof(ShowExtractNote), nameof(ShowTrace))]+ nameof(ShowArchive), nameof(ShowArchiveOptions), nameof(ShowExtractNote),- nameof(ShowSaveEveryFrame))]++ nameof(ShowSaveEveryFrame), nameof(ShowTrace))]private Choice<string> _target;+ private VideoCodec _videoCodecValue;+ private AudioCodec _audioCodecValue;++ /// <summary>The video codecs the target can hold (H.264 / VP9, HEVC, AV1); one entry for most targets.</summary>+ public IReadOnlyList<Choice<VideoCodec>> VideoCodecs =>+ [.. MediaCodecs.VideoCodecsFor(TargetId).Select(c => new Choice<VideoCodec>(c, _loc[c switch+ {+ VideoCodec.Hevc => "presets.video_codec.hevc",+ VideoCodec.Av1 => "presets.video_codec.av1",+ _ => TargetId == "webm" ? "presets.video_codec.vp9" : "presets.video_codec.h264",+ }]))];++ /// <summary>The chosen video codec; a codec the target can't hold shows (and is saved) as its usual one.</summary>+ public Choice<VideoCodec> VideoCodecChoice+ {+ get => VideoCodecs.FirstOrDefault(c => c.Value == _videoCodecValue) ?? VideoCodecs[0];+ set+ {+ // The combo box clears its selection while its list is replaced.+ if (value is null || value.Value == _videoCodecValue)+ return;+ _videoCodecValue = value.Value;+ OnPropertyChanged();+ }+ }++ /// <summary>The audio codecs the target can hold (AAC or ALAC for M4A); one entry for most targets.</summary>+ public IReadOnlyList<Choice<AudioCodec>> AudioCodecs =>+ [.. MediaCodecs.AudioCodecsFor(TargetId).Select(c => new Choice<AudioCodec>(c, _loc[c == AudioCodec.Alac ? "presets.audio_codec.alac" : "presets.audio_codec.aac"]))];++ /// <summary>The chosen audio codec; ALAC is lossless, so it has no quality or bitrate.</summary>+ public Choice<AudioCodec> AudioCodecChoice+ {+ get => AudioCodecs.FirstOrDefault(c => c.Value == _audioCodecValue) ?? AudioCodecs[0];+ set+ {+ if (value is null || value.Value == _audioCodecValue)+ return;+ _audioCodecValue = value.Value;+ OnPropertyChanged();+ OnPropertyChanged(nameof(ShowMediaQuality));+ OnPropertyChanged(nameof(ShowAudioBitrate));+ OnPropertyChanged(nameof(ShowMedia));+ }+ }+[ObservableProperty, NotifyPropertyChangedFor(nameof(ShowPercent), nameof(ShowLongEdge), nameof(ShowWidth))]private Choice<ResizeMode> _resize;@@@ -215,9 -283,13 +286,15 @@@[ObservableProperty] private bool _removeAudio;[ObservableProperty] private Choice<ArchiveLevel> _archiveLevel;[ObservableProperty] private bool _combineIntoOne;+ [ObservableProperty] private bool _saveEveryFrame;+ [ObservableProperty] private int _frameInterval = 1;+ [ObservableProperty, NotifyPropertyChangedFor(nameof(ShowTraceColors))]+ private Choice<TracingMode> _traceMode;++ [ObservableProperty] private int _traceColors;+ [ObservableProperty] private int _traceDetail;+private string TargetId => Target.Value;private FormatCategory? TargetCategory => FormatRegistry.FindById(TargetId)?.Category;private bool TargetIsImage => TargetId == BuiltInData.SameAsSource || TargetCategory == FormatCategory.Image;@@@ -252,7 -335,12 +340,13 @@@public bool ShowArchiveOptions => ShowArchive && TargetId != FormatRegistry.Folder;/// <summary>"Extract" has nothing to set; a line says what it does instead.</summary>public bool ShowExtractNote => TargetId == FormatRegistry.Folder;+ public bool ShowSaveEveryFrame => TargetId is "jpg" or "jpeg" or "png";+ /// <summary>+ /// Tracing options: raster images reach SVG (and DXF / DWG through it) only by tracing. For other sources (a+ /// drawing, a CAD file) the options are ignored.+ /// </summary>+ public bool ShowTrace => TargetId is "svg" or "svgz" or "dxf" or "dwg";+ public bool ShowTraceColors => TraceMode.Value == TracingMode.Color;public bool ShowPercent => Resize.Value == ResizeMode.Percent;public bool ShowLongEdge => Resize.Value == ResizeMode.LongEdge;public bool ShowWidth => Resize.Value == ResizeMode.Width;@@@ -316,10 -411,13 +417,15 @@@media.AudioChannels = AudioChannels.Value;media.AudioSampleRate = SampleRate.Value;media.WavFormat = WavFormat.Value;+ media.VideoCodec = MediaCodecs.Effective(TargetId, _videoCodecValue);+ media.AudioCodec = MediaCodecs.Effective(TargetId, _audioCodecValue);+ media.SaveEveryFrame = SaveEveryFrame;+ media.FrameInterval = Math.Clamp(FrameInterval, 1, 1000);_original.Archive.Level = ArchiveLevel.Value;_original.Archive.CombineIntoOne = CombineIntoOne;+ _original.Trace.Mode = TraceMode.Value;+ _original.Trace.Colors = Math.Clamp(TraceColors, TracingOptions.MinColors, TracingOptions.MaxColors);+ _original.Trace.Detail = Math.Clamp(TraceDetail, 0, 100);var output = _original.Output;output.Location = Location.Value;diff --cc src/Filee.Core/Presets/Preset.csindex 0a270d60,72550948..50166e77--- a/src/Filee.Core/Presets/Preset.cs+++ b/src/Filee.Core/Presets/Preset.cs@@@ -225,18 -355,18 +355,27 @@@ public sealed class MediaOption/// <summary>Sample rate in Hz of a WAV file (8000 … 48000); 0 keeps the source's.</summary>public int AudioSampleRate { get; set; }- /// <summary>How a WAV file stores its samples.</summary>+ /// <summary>How a WAV (or W64) file stores its samples.</summary>public WavSampleFormat WavFormat { get; set; } = WavSampleFormat.Pcm16;+ /// <summary>+ /// Video codec for targets that can hold several (<see cref="MediaCodecs.VideoCodecsFor"/>); targets that can't+ /// hold the chosen one use their usual codec.+ /// </summary>+ public VideoCodec VideoCodec { get; set; } = VideoCodec.Default;++ /// <summary>Audio codec for targets that can hold several (<see cref="MediaCodecs.AudioCodecsFor"/>).</summary>+ public AudioCodec AudioCodec { get; set; } = AudioCodec.Default;++ /// <summary>Video → image: save every frame as an individual image instead of a single still frame.</summary>+ public bool SaveEveryFrame { get; set; }++ /// <summary>With <see cref="SaveEveryFrame"/>: extract every Nth frame (1 = every frame).</summary>+ public int FrameInterval { get; set; } = 1;++ /// <summary>With <see cref="SaveEveryFrame"/>: target frames per second (0 = keep source rate).</summary>+ public double FramesPerSecond { get; set; }+public MediaOptions Clone() => (MediaOptions)MemberwiseClone();}diff --cc src/Filee.Core/Settings/AppSettings.csindex e6e0ebc4,1701b12f..ccda08f3--- a/src/Filee.Core/Settings/AppSettings.cs+++ b/src/Filee.Core/Settings/AppSettings.cs@@@ -50,7 -50,7 +50,7 @@@ public sealed class DonutSettingpublic sealed class AppSettings{/// <summary>Current schema version. Increase when the format changes and add a migration.</summary>- public const int CurrentSchemaVersion = 10;- public const int CurrentSchemaVersion = 17;++ public const int CurrentSchemaVersion = 18;public int SchemaVersion { get; set; } = CurrentSchemaVersion;diff --cc src/Filee.Core/Settings/UserDataStore.csindex 12169a1b,9b0f3880..cfae4bf6--- a/src/Filee.Core/Settings/UserDataStore.cs+++ b/src/Filee.Core/Settings/UserDataStore.cs@@@ -353,17 -393,92 +393,104 @@@ internal static class SettingsMigrationchanged |= Offer(presets, profiles, "pdf", "pdf-long-image", "to-jpg");}- // v10: Video frame sequence extraction presets (PNG and JPG), on no donut to avoid accidental clicks.- if (from < 10)+ // v10: "Remove background" (signatures, stamps, logos → transparent PNG), on no donut like HEIC: users add it+ // in Settings → Toolbar.+ if (from < 10 && presets.All(p => p.Id != "remove-background"))+ {+ presets.Add(BuiltInData.CreatePresets().Single(p => p.Id == "remove-background"));+ changed = true;+ }++ // v11: more document formats (Org, AsciiDoc, Typst, ... through Pandoc; flat OpenDocument, templates,+ // ClarisWorks, ... through LibreOffice; KEPUB built in). Built-in donuts learn the new extensions unless+ // another donut already has them, and the e-books donut gets KEPUB after MOBI.+ if (from < 11)+ {+ if (presets.All(p => p.Id != "to-kepub"))+ {+ presets.Add(BuiltInData.CreatePresets().Single(p => p.Id == "to-kepub"));+ changed = true;+ changed |= Offer(presets, profiles, "ebooks", "to-kepub", "to-mobi");+ }+ changed |= LearnExtensions(profiles, out _);+ }++ // v12: HEVC / AV1 video, ALAC and the new audio formats (WavPack, TTA, APE, DSD, ...), and a subtitles donut+ // after the audio donut. The video donut offers "MP4 HEVC" and "Extract subtitles".+ if (from < 12)+ changed |= AddCodecsAndSubtitles(presets, profiles);++ // v13: more image formats (APNG, MNG, QOI, DDS, DICOM, OpenEXR, …, Fujifilm's .hif): the images donut learns+ // their extensions unless another donut already has them.+ if (from < 13)+ changed |= LearnExtensions(profiles, out _);++ // v14: structured data (JSON, YAML, TOML, XML, vCard) gets its own donut after "fonts", Outlook MSG joins+ // the documents donut next to EML, and the spreadsheets donut gets JSON after CSV.+ if (from < 14)+ changed |= AddData(presets, profiles);++ // v15: 3D models (GLB, glTF, STL, OBJ, 3MF, PLY) get presets and their own donut after "data" (else after+ // "fonts", else before the mixed-files one), with the extensions no donut of the user takes yet.+ if (from < 15)+ changed |= AddModels(presets, profiles);++ // v16: raster → SVG tracing ("Trace to SVG" in colour, "Line art to SVG" in black), on the images donut after+ // PDF.+ if (from < 16)+ {+ foreach (var preset in BuiltInData.TracePresets().Where(p => presets.All(existing => existing.Id != p.Id)))+ {+ presets.Add(preset);+ changed = true;+ }+ changed |= Offer(presets, profiles, "images", "trace-svg", "to-pdf");+ changed |= Offer(presets, profiles, "images", "trace-line-art", "trace-svg");+ }++ // v17: rotate / flip presets and the "Rotate" / "Flip" groups that fan them out, on no donut, after "Remove+ // background" as in a new library. Present already but saved since by a Filee before 17 (it reads and writes+ // an older schema, so back and forth between versions comes here again): that one dropped what it didn't+ // know, the rotation and the group, and left a preset that re-encodes unturned. Those parts are put back, the+ // user's own changes (name, quality, file names) stay.+ if (from < 17)+ {+ var at = presets.FindIndex(p => p.Id == "remove-background");+ at = at < 0 ? presets.Count : at + 1;+ foreach (var tool in BuiltInData.ImageToolPresets())+ {+ if (presets.FirstOrDefault(p => p.Id == tool.Id) is not { } existing)+ {+ presets.Insert(Math.Min(at++, presets.Count), tool);+ changed = true;+ }+ else if (tool.IsGroup && !existing.IsGroup)+ {+ existing.Kind = PresetKind.Group;+ existing.SubPresetIds = [.. tool.SubPresetIds];+ existing.TargetFormat = tool.TargetFormat;+ changed = true;+ }+ else if (!tool.IsGroup && !existing.Image.TurnsOrMirrors)+ {+ existing.Image.Rotation = tool.Image.Rotation;+ existing.Image.Flip = tool.Image.Flip;+ changed = true;+ }+ }+ }++++ // v18: Video frame sequence extraction presets (PNG and JPG), on no donut to avoid accidental clicks.++ if (from < 18)+ {+ foreach (var id in new[] { "extract-frames-png", "extract-frames-jpg" })+ {+ if (presets.Any(p => p.Id == id))+ continue;+ presets.Add(BuiltInData.CreatePresets().Single(p => p.Id == id));+ changed = true;+ }+ }return changed;}diff --cc src/Filee.Engines/Media/FfmpegConverter.csindex d391b61c,5bc2877a..8d807cd9--- a/src/Filee.Engines/Media/FfmpegConverter.cs+++ b/src/Filee.Engines/Media/FfmpegConverter.cs@@@ -50,10 -55,15 +55,16 @@@ public sealed partial class FfmpegConvereturn[.. from source in videos from target in videoTargets select new ConversionEdge(source, target),+ .. from source in videos from target in new[] { "jpg", "jpeg" } select new ConversionEdge(source, target, 11),+ // Subtitles out of a video. SRT is the hub to the other subtitle formats (the subtitle engine takes it on),+ // so ASS and WebVTT cost a little more and are only taken when they are the target.+ .. from source in videos from target in MediaEncoding.SubtitleTargets.Keys+ select new ConversionEdge(source, target, target == "srt" ? 10 : 11),.. videos.Select(source => new ConversionEdge(source, "gif", 15)),+ .. videos.Select(source => new ConversionEdge(source, "apng", 15)),.. from source in audios from target in MediaEncoding.AudioTargets.Keys select new ConversionEdge(source, target),.. MediaEncoding.PictureToVideoTargets.Select(target => new ConversionEdge("gif", target)),+ .. MediaEncoding.PictureToVideoTargets.Select(target => new ConversionEdge("apng", target, 11)),.. MediaEncoding.PictureToVideoTargets.Select(target => new ConversionEdge("png", target, 11)),// HEIC: ImageMagick reads, x265 encodes, Filee writes the container (see Heic/HeicWriter)... ImageEncoder.Sources.Select(source => new ConversionEdge(source, "heic")),@@@ -103,7 -110,7 +114,7 @@@// Throws for a missing stream before anything is written (an existing file of that name stays untouched).var passes = still? MediaEncoding.PlanStill(input, output, step.To, step.Preset.Media, info)- : MediaEncoding.Plan(input, output, step.To, step.Preset.Media, info, step.WorkDirectory, cover, step.Preset.Image.Quality);- : MediaEncoding.Plan(input, output, step.To, step.Preset.Media, info, step.WorkDirectory, cover, EncodersOf(ffmpeg));++ : MediaEncoding.Plan(input, output, step.To, step.Preset.Media, info, step.WorkDirectory, cover, EncodersOf(ffmpeg), step.Preset.Image.Quality);var duration = still ? MediaEncoding.StillDuration : info.Duration;try{@@@ -185,117 -192,44 +196,155 @@@[GeneratedRegex(@"version\s+n?(\d+(?:\.\d+)+|\S+)")]private static partial Regex VersionPattern();+ private static readonly ConcurrentDictionary<string, IReadOnlySet<string>?> Encoders = new();++ /// <summary>+ /// The encoders of <paramref name="ffmpeg"/> (<c>ffmpeg -encoders</c>), cached per executable: a copy the user+ /// picked may lack x265 or SVT-AV1. Null (assume Filee's build) when the list can't be read.+ /// </summary>+ private static IReadOnlySet<string>? EncodersOf(string ffmpeg) =>+ Encoders.GetOrAdd($"{ffmpeg}|{File.GetLastWriteTimeUtc(ffmpeg).Ticks}", _ =>+ {+ try+ {+ using var process = Process.Start(new ProcessStartInfo(ffmpeg, "-hide_banner -encoders")+ {+ UseShellExecute = false,+ CreateNoWindow = true,+ RedirectStandardOutput = true,+ RedirectStandardError = true,+ });+ if (process is null)+ return null;+ process.ErrorDataReceived += (_, _) => { };+ process.BeginErrorReadLine();+ var list = process.StandardOutput.ReadToEnd();+ if (!process.WaitForExit(10_000) || process.ExitCode != 0)+ return null;+ // " V....D libx265 libx265 H.265 / HEVC (codec hevc)"+ return list.Split('\n')+ .Select(line => line.Split(' ', StringSplitOptions.RemoveEmptyEntries))+ .Where(parts => parts.Length >= 2 && parts[0].Length == 6 && parts[0][0] is 'V' or 'A' or 'S')+ .Select(parts => parts[1])+ .ToHashSet(StringComparer.Ordinal);+ }+ catch (Exception ex) when (ex is InvalidOperationException or System.ComponentModel.Win32Exception or IOException)+ {+ return null;+ }+ });++ private static readonly HashSet<string> VideoExtensions = new(StringComparer.OrdinalIgnoreCase)+ {+ ".mp4", ".m4v", ".mov", ".mkv", ".webm", ".avi", ".wmv", ".flv", ".mpg", ".mpeg",+ ".ts", ".m2ts", ".3gp", ".3g2", ".ogv", ".vob", ".dv", ".mxf"+ };++ private static bool IsVideoFrameSplitting(ConversionStep step, MediaInfo info, out string imageExt)+ {+ imageExt = "";+ if (!step.Preset.Media.SaveEveryFrame)+ return false;++ var isSourceVideo = (FormatRegistry.FindById(step.From)?.Category == FormatCategory.Video)+ || (FormatRegistry.Detect(step.InputPath)?.Category == FormatCategory.Video)+ || VideoExtensions.Contains(Path.GetExtension(step.InputPath))+ || (info.Video is not null && step.From is not "png" and not "gif");++ if (!isSourceVideo)+ return false;++ var targetExt = step.To.TrimStart('.').ToLowerInvariant();+ if (targetExt is "jpg" or "jpeg")+ {+ imageExt = "jpg";+ return true;+ }+ if (targetExt is "png")+ {+ imageExt = "png";+ return true;+ }++ var presetTarget = step.Preset.TargetFormat.TrimStart('.').ToLowerInvariant();+ if (presetTarget is "jpg" or "jpeg")+ {+ imageExt = "jpg";+ return true;+ }+ if (presetTarget is "png")+ {+ imageExt = "png";+ return true;+ }++ return false;+ }++ private static async Task<IReadOnlyList<string>> ExtractFramesAsync(+ string ffmpeg,+ ConversionStep step,+ string input,+ MediaInfo info,+ string imageExt,+ IProgress<double>? progress,+ CancellationToken cancellationToken)+ {+ var allocated = step.Output.Allocate(imageExt);+ if (allocated is null)+ return [];++ var outputDirectory = Path.GetDirectoryName(allocated)!;+ var videoFilename = Path.GetFileNameWithoutExtension(allocated);+ if (string.IsNullOrEmpty(videoFilename))+ videoFilename = FormatRegistry.NameWithoutExtension(step.InputPath);++ var framesSubfolder = Path.Combine(outputDirectory, $"{videoFilename}_frames");+ for (var n = 2; Directory.Exists(framesSubfolder); n++)+ framesSubfolder = Path.Combine(outputDirectory, $"{videoFilename}_frames ({n})");++ Directory.CreateDirectory(framesSubfolder);++ var outputPattern = Path.Combine(framesSubfolder, $"frame_%06d.{imageExt}");+ var args = MediaEncoding.FrameSequence(+ input,+ outputPattern,+ imageExt,+ info.Video,+ step.Preset.Image.Quality,+ step.Preset.Media.FrameInterval,+ step.Preset.Media.FramesPerSecond);++ var pass = new FfmpegPass(args, 1);++ try+ {+ await RunPassAsync(ffmpeg, pass, info.Duration, progress, done: 0, cancellationToken);++ if (!Directory.Exists(framesSubfolder) || !Directory.EnumerateFiles(framesSubfolder).Any())+ throw new InvalidOperationException("FFmpeg did not write any frames.");+ }+ catch+ {+ TryDeleteDirectory(framesSubfolder);+ throw;+ }++ progress?.Report(1);+ return [framesSubfolder];+ }++ private static void TryDeleteDirectory(string path)+ {+ try+ {+ if (Directory.Exists(path))+ Directory.Delete(path, recursive: true);+ }+ catch (IOException) { }+ catch (UnauthorizedAccessException) { }+ }+private static void TryDelete(string path){trydiff --cc src/Filee.Engines/Media/MediaEncoding.csindex 736ec9c9,ff791f17..d9635583--- a/src/Filee.Engines/Media/MediaEncoding.cs+++ b/src/Filee.Engines/Media/MediaEncoding.cs@@@ -117,72 -140,30 +140,78 @@@ internal static class MediaEncodin/// </summary>/// <param name="workDirectory">Scratch folder (the GIF palette goes there).</param>/// <param name="cover">The source's cover for targets FFmpeg can't put a picture stream into (<see cref="CoverArt"/>).</param>+ /// <param name="encoders">The encoders the FFmpeg in use has (<c>ffmpeg -encoders</c>); null assumes the pinned build's.</param>/// <exception cref="InvalidOperationException">The file lacks the stream the target needs (e.g. no audio track).</exception>public static IReadOnlyList<FfmpegPass> Plan(string input, string output, string target, MediaOptions options, MediaInfo info, string workDirectory,- CoverExtras? cover = null, int imageQuality = 90)- CoverExtras? cover = null, IReadOnlySet<string>? encoders = null)++ CoverExtras? cover = null, IReadOnlySet<string>? encoders = null, int imageQuality = 90){if (target == "gif")return AnimatedGif(input, output, options, info, workDirectory);+ if (target == "apng")+ return [new FfmpegPass(AnimatedPng(input, output, options, info), 1)];+ if (target is "jpg" or "jpeg")+ return [new FfmpegPass(PosterFrame(input, output, info, "mjpeg", imageQuality), 1)];if (target == "png")- return [new FfmpegPass(PosterFrame(input, output, info), 1)];+ return [new FfmpegPass(PosterFrame(input, output, info, "png"), 1)];if (VideoTargets.TryGetValue(target, out var video))- return [new FfmpegPass(Video(input, output, target, video, options, info), 1)];+ return [new FfmpegPass(Video(input, output, target, video, options, info, encoders), 1)];if (AudioTargets.TryGetValue(target, out var audio))return [new FfmpegPass(Audio(input, output, target, audio, options, info, cover), 1)];+ if (SubtitleTargets.ContainsKey(target))+ return [new FfmpegPass(Subtitles(input, output, target, info), 1)];throw new NotSupportedException($"FFmpeg cannot write '{target}'.");}+ /// <summary>+ /// Maps preset image quality (1..100, 100 best) to FFmpeg's mjpeg -q:v parameter (1..31, 1 best, 2..3 visually lossless).+ /// </summary>+ public static int QualityToQv(int quality)+ {+ var clamped = Math.Clamp(quality, 1, 100);+ return Math.Clamp((int)Math.Round(2.0 + (100 - clamped) * 29.0 / 99.0), 1, 31);+ }++ /// <summary>+ /// Slices frames of a video into an image sequence in <paramref name="outputPattern"/>+ /// for focus stacking and photography analysis.+ /// </summary>+ public static List<string> FrameSequence(+ string input,+ string outputPattern,+ string imageExt,+ VideoStreamInfo? video = null,+ int quality = 90,+ int frameInterval = 1,+ double fps = 0)+ {+ List<string> args = [.. Common, "-i", input];++ var filters = new List<string>();+ if (video is not null && Math.Abs(video.SampleAspect - 1) > 0.01)+ filters.Add("scale=w='trunc(iw*sar/2)*2':h=ih,setsar=1");++ if (frameInterval > 1)+ filters.Add($"select='not(mod(n\\,{frameInterval}))'");+ else if (fps > 0)+ filters.Add($"fps={fps.ToString(CultureInfo.InvariantCulture)}");++ if (filters.Count > 0)+ args.AddRange(["-vf", string.Join(",", filters)]);++ if (frameInterval > 1)+ args.AddRange(["-fps_mode", "vfr"]);++ if (imageExt is "jpg" or "jpeg")+ args.AddRange(["-q:v", QualityToQv(quality).ToString(CultureInfo.InvariantCulture)]);++ args.AddRange(["-progress", "pipe:1", outputPattern]);+ return args;+ }+// ───────────────────────── Video ─────────────────────────- private static List<string> Video(string input, string output, string target, MediaTarget spec, MediaOptions options, MediaInfo info)+ private static List<string> Video(string input, string output, string target, MediaTarget spec, MediaOptions options, MediaInfo info,+ IReadOnlySet<string>? encoders){var video = info.Video ?? throw new InvalidOperationException("The file has no video stream.");// An input without sound is fine: the output simply has no audio track.diff --cc tests/Filee.Core.Tests/SmallParsersTests.csindex 1f5a2813,b33fe152..f0edbf6b--- a/tests/Filee.Core.Tests/SmallParsersTests.cs+++ b/tests/Filee.Core.Tests/SmallParsersTests.cs@@@ -64,32 -108,11 +108,37 @@@ public class BuiltInDataTestpublic void Preset_targets_are_known_formats(){foreach (var preset in BuiltInData.CreatePresets())- Assert.True(preset.TargetFormat == BuiltInData.SameAsSource || FormatRegistry.FindById(preset.TargetFormat) is not null, preset.Id);+ {+ if (preset.IsGroup)+ Assert.Equal(Preset.GroupTarget, preset.TargetFormat); // none an older Filee could run it with+ else+ Assert.True(preset.TargetFormat == BuiltInData.SameAsSource || FormatRegistry.FindById(preset.TargetFormat) is not null, preset.Id);+ }}++ [Fact]+ public void Extract_frames_preset_is_properly_configured()+ {+ var presets = BuiltInData.CreatePresets();+ var pngPreset = Assert.Single(presets, p => p.Id == "extract-frames-png" || p.NameKey == "preset.extract_frames_png");++ Assert.Equal("png", pngPreset.TargetFormat);+ Assert.True(pngPreset.Media.SaveEveryFrame);+ Assert.Equal(1, pngPreset.Media.FrameInterval);++ var jpgPreset = Assert.Single(presets, p => p.Id == "extract-frames-jpg" || p.NameKey == "preset.extract_frames_jpg");++ Assert.Equal("jpg", jpgPreset.TargetFormat);+ Assert.True(jpgPreset.Media.SaveEveryFrame);+ Assert.Equal(1, jpgPreset.Media.FrameInterval);+ Assert.Equal(90, jpgPreset.Image.Quality);++ // Ensure they are NOT added to any default donut profile to prevent accidental frame splitting+ var profiles = BuiltInData.CreateProfiles();+ foreach (var profile in profiles)+ {+ Assert.DoesNotContain(pngPreset.Id, profile.PresetIds);+ Assert.DoesNotContain(jpgPreset.Id, profile.PresetIds);+ }+ }}diff --cc tests/Filee.Core.Tests/UserDataStoreTests.csindex 4e889447,36e7c4bc..87b9fe98--- a/tests/Filee.Core.Tests/UserDataStoreTests.cs+++ b/tests/Filee.Core.Tests/UserDataStoreTests.cs@@@ -202,17 -295,279 +295,301 @@@ public class UserDataStoreTestAssert.True(SettingsMigrations.ApplyToLibrary(9, presets, profiles));+ var preset = presets.Single(p => p.Id == "remove-background");+ Assert.True(preset.Image.RemoveBackground);+ Assert.Equal("png", preset.TargetFormat);+ Assert.DoesNotContain(profiles, p => p.PresetIds.Contains("remove-background"));+ Assert.False(SettingsMigrations.ApplyToLibrary(9, presets, profiles)); // once only+ }+++ [Fact]++ public void Version_17_libraries_get_the_extract_frames_presets()++ {++ var presets = BuiltInData.CreatePresets();++ presets.RemoveAll(p => p.Id is "extract-frames-png" or "extract-frames-jpg");++ var profiles = BuiltInData.CreateProfiles();++++ Assert.True(SettingsMigrations.ApplyToLibrary(17, presets, profiles));+++ var pngPreset = presets.Single(p => p.Id == "extract-frames-png");+ Assert.True(pngPreset.Media.SaveEveryFrame);+ Assert.Equal("png", pngPreset.TargetFormat);++ var jpgPreset = presets.Single(p => p.Id == "extract-frames-jpg");+ Assert.True(jpgPreset.Media.SaveEveryFrame);+ Assert.Equal("jpg", jpgPreset.TargetFormat);++ Assert.DoesNotContain(profiles, p => p.PresetIds.Contains("extract-frames-png"));+ Assert.DoesNotContain(profiles, p => p.PresetIds.Contains("extract-frames-jpg"));- Assert.False(SettingsMigrations.ApplyToLibrary(9, presets, profiles)); // once only++ Assert.False(SettingsMigrations.ApplyToLibrary(17, presets, profiles)); // once only++ }+++ [Fact]+ public void Version_13_libraries_get_the_data_donut_msg_files_and_json_for_spreadsheets()+ {+ // As written with schema 13: no data presets or donut, no MSG on the documents donut, no JSON on the spreadsheets+ // donut; and a donut of the user that already takes YAML.+ var presets = BuiltInData.CreatePresets();+ presets.RemoveAll(p => BuiltInData.DataPresets().Any(d => d.Id == p.Id));+ var profiles = BuiltInData.CreateProfiles();+ profiles.RemoveAll(p => p.Id == "data");+ profiles.Single(p => p.Id == "office").Extensions.Remove("msg");+ profiles.Single(p => p.Id == "spreadsheets").PresetIds.Remove("to-json");+ profiles.Insert(0, new ToolbarProfile { Id = "mine", Name = "Mine", Extensions = ["yml"] });++ Assert.True(SettingsMigrations.ApplyToLibrary(13, presets, profiles));++ Assert.All(BuiltInData.DataPresets(), d => Assert.Contains(presets, p => p.Id == d.Id));+ var ids = profiles.Select(p => p.Id).ToList();+ Assert.Equal(ids.IndexOf("fonts") + 1, ids.IndexOf("data"));+ var data = profiles.Single(p => p.Id == "data");+ Assert.Contains("json", data.Extensions);+ Assert.Contains("yaml", data.Extensions);+ Assert.DoesNotContain("yml", data.Extensions); // the user's donut keeps it+ Assert.Equal(["to-json", "to-yaml", "to-toml", "to-xml", "to-csv", "to-xlsx"], data.PresetIds);+ Assert.Contains("msg", profiles.Single(p => p.Id == "office").Extensions);+ var sheets = profiles.Single(p => p.Id == "spreadsheets").PresetIds;+ Assert.Equal(sheets.IndexOf("to-csv") + 1, sheets.IndexOf("to-json"));+ Assert.DoesNotContain(profiles, p => p.PresetIds.Contains("to-eml") || p.PresetIds.Contains("to-vcf"));+ Assert.False(SettingsMigrations.ApplyToLibrary(13, presets, profiles)); // once only++ var all = profiles.SelectMany(p => p.Extensions).ToList();+ Assert.Equal(all.Count, all.Distinct(StringComparer.OrdinalIgnoreCase).Count());+ }++ [Fact]+ public void Version_13_settings_get_the_data_engine_after_email()+ {+ using var dir = new TempDir();+ File.WriteAllText(Path.Combine(dir.Path, "settings.json"),+ """{ "schemaVersion": 13, "enginePriority": ["magick", "email", "vector", "pandoc", "libreoffice"] }""");++ var store = new UserDataStore(dir.Path);+ store.Load();++ // ... and, from schema 15, the 3D model engine before Pandoc (no CAD or archive engine in this list).+ Assert.Equal(["magick", "email", "data", "vector", "model3d", "pandoc", "libreoffice"], store.Settings.EnginePriority);+ }++ [Fact]+ public void Version_12_libraries_open_the_new_image_formats_on_the_images_donut()+ {+ // As written with schema 12: the images donut knows no APNG, QOI, DICOM or .hif; a donut of the user takes DDS.+ var presets = BuiltInData.CreatePresets();+ var profiles = BuiltInData.CreateProfiles();+ var images = profiles.Single(p => p.Id == "images");+ images.Extensions.RemoveAll(e => e is "apng" or "qoi" or "dcm" or "hif" or "dds");+ profiles.Insert(0, new ToolbarProfile { Id = "game", Name = "Game textures", Extensions = ["dds"] });++ Assert.True(SettingsMigrations.ApplyToLibrary(12, presets, profiles));++ Assert.Contains("apng", images.Extensions);+ Assert.Contains("qoi", images.Extensions);+ Assert.Contains("dcm", images.Extensions);+ Assert.Contains("hif", images.Extensions);+ Assert.DoesNotContain("dds", images.Extensions);+ Assert.False(SettingsMigrations.ApplyToLibrary(12, presets, profiles)); // once only+ }++ [Fact]+ public void Version_11_libraries_get_codecs_new_audio_formats_and_a_subtitles_donut()+ {+ // As written with schema 11: no HEVC / AV1 / ALAC / subtitle presets, no subtitles donut, the video donut and+ // the audio extensions of that time, and a donut of the user that already takes .ape.+ var added = BuiltInData.CodecAndSubtitlePresets().Select(p => p.Id).ToHashSet();+ var presets = BuiltInData.CreatePresets().Where(p => !added.Contains(p.Id)).ToList();+ var profiles = BuiltInData.CreateProfiles().Where(p => p.Id != "subtitles").ToList();+ foreach (var profile in profiles)+ profile.PresetIds.RemoveAll(added.Contains);+ var audio = profiles.Single(p => p.Id == "audio");+ audio.Extensions.RemoveAll(e => e is "wv" or "tta" or "w64" or "eac3" or "ec3" or "ape" or "mpc" or "mpp" or "mp+" or "tak"+ or "dsf" or "dff" or "dts" or "spx");+ profiles.Insert(0, new ToolbarProfile { Id = "mine", Name = "Mine", Extensions = ["ape"] });++ Assert.True(SettingsMigrations.ApplyToLibrary(11, presets, profiles));++ Assert.Contains("wv", audio.Extensions);+ Assert.Contains("dsf", audio.Extensions);+ Assert.DoesNotContain("ape", audio.Extensions); // the user's donut keeps it+ var ids = profiles.Select(p => p.Id).ToList();+ Assert.Equal(ids.IndexOf("audio") + 1, ids.IndexOf("subtitles"));+ Assert.Equal(BuiltInData.SubtitleProfile().PresetIds, profiles.Single(p => p.Id == "subtitles").PresetIds);+ Assert.Contains("smi", profiles.Single(p => p.Id == "subtitles").Extensions);+ Assert.Equal(BuiltInData.CreateProfiles().Single(p => p.Id == "video").PresetIds, profiles.Single(p => p.Id == "video").PresetIds);+ Assert.Equal(VideoCodec.Hevc, presets.Single(p => p.Id == "mp4-hevc").Media.VideoCodec);+ Assert.Equal(AudioCodec.Alac, presets.Single(p => p.Id == "to-alac").Media.AudioCodec);+ Assert.DoesNotContain(profiles, p => p.PresetIds.Contains("to-alac") || p.PresetIds.Contains("mp4-av1"));+ var all = profiles.SelectMany(p => p.Extensions).ToList();+ Assert.Equal(all.Count, all.Distinct(StringComparer.OrdinalIgnoreCase).Count());+ Assert.False(SettingsMigrations.ApplyToLibrary(11, presets, profiles)); // once only+ }++ [Fact]+ public void Version_10_libraries_get_kepub_and_the_new_document_extensions()+ {+ // As written by 1.11.x: no KEPUB preset, and the donuts without the formats added in schema 11.+ string[] added = ["org", "adoc", "typ", "mediawiki", "wiki", "dbk", "ipynb", "fodt", "ott", "cwk", "602", "ots", "fods", "otp", "fodp", "fodg", "kepub.epub"];+ var presets = BuiltInData.CreatePresets();+ presets.RemoveAll(p => p.Id == "to-kepub");+ var profiles = BuiltInData.CreateProfiles();+ foreach (var profile in profiles)+ {+ profile.PresetIds.Remove("to-kepub");+ profile.Extensions.RemoveAll(added.Contains);+ }+ // A donut of the user already handles Org files.+ profiles.Insert(0, new ToolbarProfile { Id = "mine", Name = "Mine", Extensions = ["org"] });++ Assert.True(SettingsMigrations.ApplyToLibrary(10, presets, profiles));++ Assert.Equal("kepub", presets.Single(p => p.Id == "to-kepub").TargetFormat);+ var ebooks = profiles.Single(p => p.Id == "ebooks");+ Assert.Equal(ebooks.PresetIds.IndexOf("to-mobi") + 1, ebooks.PresetIds.IndexOf("to-kepub"));+ Assert.Contains("kepub.epub", ebooks.Extensions);+ Assert.Contains("typ", profiles.Single(p => p.Id == "text").Extensions);+ Assert.DoesNotContain("org", profiles.Single(p => p.Id == "text").Extensions);+ Assert.Contains("fodt", profiles.Single(p => p.Id == "office").Extensions);+ Assert.Contains("fods", profiles.Single(p => p.Id == "spreadsheets").Extensions);+ Assert.Contains("otp", profiles.Single(p => p.Id == "presentations").Extensions);+ Assert.Contains("fodg", profiles.Single(p => p.Id == "vector").Extensions);+ foreach (var expected in BuiltInData.CreateProfiles())+ Assert.Equal(expected.PresetIds, profiles.Single(p => p.Id == expected.Id).PresetIds);+ Assert.False(SettingsMigrations.ApplyToLibrary(10, presets, profiles)); // once only+ }++ [Fact]+ public void Version_14_libraries_get_3d_model_presets_and_their_donut_after_data()+ {+ // As written with schema 14: no 3D formats.+ var modelIds = BuiltInData.ModelPresets().Select(p => p.Id).ToHashSet();+ var presets = BuiltInData.CreatePresets().Where(p => !modelIds.Contains(p.Id)).ToList();+ var profiles = BuiltInData.CreateProfiles().Where(p => p.Id != "models").ToList();++ Assert.True(SettingsMigrations.ApplyToLibrary(14, presets, profiles));++ Assert.Equal(["to-glb", "to-stl", "to-obj", "to-3mf", "to-ply", "to-gltf"], presets.Where(p => modelIds.Contains(p.Id)).Select(p => p.Id));+ var ids = profiles.Select(p => p.Id).ToList();+ Assert.Equal(ids.IndexOf("data") + 1, ids.IndexOf("models"));+ Assert.Equal(ids.IndexOf("mixed") - 1, ids.IndexOf("models"));+ var models = profiles.Single(p => p.Id == "models");+ Assert.Equal(["glb", "gltf", "stl", "obj", "3mf", "ply"], models.Extensions);+ Assert.Equal(BuiltInData.ModelProfile().PresetIds, models.PresetIds);+ Assert.False(SettingsMigrations.ApplyToLibrary(14, presets, profiles)); // once only+ }++ [Fact]+ public void The_3d_donut_leaves_out_extensions_a_profile_of_the_user_takes()+ {+ var presets = BuiltInData.CreatePresets();+ var profiles = BuiltInData.CreateProfiles().Where(p => p.Id != "models").ToList();+ profiles.Insert(0, new ToolbarProfile { Id = "printing", Name = "Printing", Extensions = ["stl", "3mf"] });++ Assert.True(SettingsMigrations.ApplyToLibrary(14, presets, profiles));++ Assert.Equal(["glb", "gltf", "obj", "ply"], profiles.Single(p => p.Id == "models").Extensions);+ }++ [Fact]+ public void Version_15_libraries_get_the_tracing_presets_on_the_images_donut_after_pdf()+ {+ // As written before tracing: no trace presets, and the images donut without them.+ var presets = BuiltInData.CreatePresets();+ presets.RemoveAll(p => p.Id is "trace-svg" or "trace-line-art");+ var profiles = BuiltInData.CreateProfiles();+ var images = profiles.Single(p => p.Id == "images");+ images.PresetIds.RemoveAll(id => id is "trace-svg" or "trace-line-art");++ Assert.True(SettingsMigrations.ApplyToLibrary(15, presets, profiles));++ Assert.Equal(TracingMode.Color, presets.Single(p => p.Id == "trace-svg").Trace.Mode);+ Assert.Equal(TracingMode.BlackAndWhite, presets.Single(p => p.Id == "trace-line-art").Trace.Mode);+ Assert.All(presets.Where(p => p.Id.StartsWith("trace-", StringComparison.Ordinal)), p => Assert.Equal("svg", p.TargetFormat));+ Assert.Equal(BuiltInData.CreateProfiles().Single(p => p.Id == "images").PresetIds, images.PresetIds);+ Assert.False(SettingsMigrations.ApplyToLibrary(15, presets, profiles)); // once only+ }++ [Fact]+ public void Trace_options_survive_a_save_and_load()+ {+ using var dir = new TempDir();+ var store = new UserDataStore(dir.Path);+ store.Load();+ var preset = store.Presets.Single(p => p.Id == "trace-svg");+ preset.Trace.Colors = 6;+ preset.Trace.Detail = 80;+ store.SaveLibrary();++ var reloaded = new UserDataStore(dir.Path);+ reloaded.Load();+ var trace = reloaded.Presets.Single(p => p.Id == "trace-svg").Trace;+ Assert.Equal((TracingMode.Color, 6, 80), (trace.Mode, trace.Colors, trace.Detail));+ Assert.Equal(TracingMode.BlackAndWhite, reloaded.Presets.Single(p => p.Id == "trace-line-art").Trace.Mode);+ }++ [Fact]+ public void Version_16_libraries_get_rotate_and_flip_presets_and_groups_on_no_donut()+ {+ var presets = BuiltInData.CreatePresets();+ presets.RemoveAll(p => p.Id is "rotate-left" or "rotate-right" or "rotate-180" or "flip-horizontal" or "flip-vertical" or "rotate" or "flip");+ var profiles = BuiltInData.CreateProfiles();++ Assert.True(SettingsMigrations.ApplyToLibrary(16, presets, profiles));++ var rotate = presets.Single(p => p.Id == "rotate");+ Assert.True(rotate.IsGroup);+ Assert.Equal(["rotate-left", "rotate-right", "rotate-180"], rotate.SubPresetIds);+ Assert.Equal(ImageRotation.Left90, presets.Single(p => p.Id == "rotate-left").Image.Rotation);+ Assert.Equal(ImageFlip.Horizontal, presets.Single(p => p.Id == "flip-horizontal").Image.Flip);+ Assert.DoesNotContain(profiles, p => p.PresetIds.Any(id => id.StartsWith("rotate") || id.StartsWith("flip")));+ Assert.False(SettingsMigrations.ApplyToLibrary(16, presets, profiles)); // once only+ // Where a new library has them: after "Remove background".+ var background = presets.FindIndex(p => p.Id == "remove-background");+ Assert.Equal("rotate-left", presets[background + 1].Id);+ }++ [Fact]+ public void A_rotation_from_a_newer_Filee_reads_as_none_and_the_other_presets_still_load()+ {+ using var dir = new TempDir();+ var store = new UserDataStore(dir.Path);+ store.Load();+ store.SaveLibrary();+ var path = Path.Combine(dir.Path, "presets.json");+ var json = File.ReadAllText(path);+ Assert.Contains("\"rotation\": \"Left90\"", json);+ File.WriteAllText(path, json.Replace("\"rotation\": \"Left90\"", "\"rotation\": \"Transpose\"")+ .Replace("\"flip\": \"Vertical\"", "\"flip\": 7"));++ var reloaded = new UserDataStore(dir.Path);+ reloaded.Load();++ Assert.Equal(ImageRotation.None, reloaded.FindPreset("rotate-left")!.Image.Rotation);+ Assert.Equal(ImageFlip.None, reloaded.FindPreset("flip-vertical")!.Image.Flip);+ Assert.Equal(ImageRotation.Right90, reloaded.FindPreset("rotate-right")!.Image.Rotation); // the rest as saved+ Assert.False(File.Exists(path + ".broken"));+ }++ [Fact]+ public void Back_from_an_older_Filee_rotate_and_flip_work_again_and_keep_the_users_changes()+ {+ // What a Filee before 17 leaves after saving: kind, members and rotation dropped, the rest as it was.+ var presets = BuiltInData.CreatePresets();+ var left = presets.Single(p => p.Id == "rotate-left");+ left.Image.Rotation = ImageRotation.None;+ left.Name = "Turn left";+ var rotate = presets.Single(p => p.Id == "rotate");+ rotate.Kind = PresetKind.Convert;+ rotate.SubPresetIds = [];+ var profiles = BuiltInData.CreateProfiles();++ Assert.True(SettingsMigrations.ApplyToLibrary(16, presets, profiles));++ Assert.Equal(ImageRotation.Left90, left.Image.Rotation);+ Assert.Equal("Turn left", left.Name);+ Assert.True(rotate.IsGroup);+ Assert.Equal(["rotate-left", "rotate-right", "rotate-180"], rotate.SubPresetIds);+ Assert.Equal(Preset.GroupTarget, rotate.TargetFormat);+ Assert.Single(presets, p => p.Id == "rotate-left"); // repaired, not added twice}[Fact]diff --cc tests/Filee.Engines.Tests/MediaTests.csindex ae8fdb07,06f8f3dd..32ae5ad8--- a/tests/Filee.Engines.Tests/MediaTests.cs+++ b/tests/Filee.Engines.Tests/MediaTests.cs@@@ -50,10 -50,21 +50,23 @@@ public class MediaTests(EngineFixture f[InlineData("gif", "mp4")][InlineData("gif", "webm")][InlineData("png", "mov")]+ [InlineData("apng", "mp4")]+ [InlineData("mov", "apng")][InlineData("rm", "mp4")][InlineData("dss", "mp3")]+ [InlineData("mp4", "jpg")]+ [InlineData("mp4", "png")]+ [InlineData("ape", "flac")]+ [InlineData("wv", "mp3")]+ [InlineData("tta", "wv")]+ [InlineData("mpc", "m4a")]+ [InlineData("tak", "flac")]+ [InlineData("dsf", "wav")]+ [InlineData("dff", "flac")]+ [InlineData("dts", "eac3")]+ [InlineData("spx", "ogg")]+ [InlineData("wav", "w64")]+ [InlineData("mkv", "eac3")]public void Media_conversions_take_one_ffmpeg_step(string from, string to){var route = Planner().Plan(from, to);