Skip to content

armgit / Filee

Public Imported from GitHub
0

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.

Settings schema 19: the frame presets after "Split PDF"

KnifeLemon33c5a61c3101
diff --git a/src/Filee.Core/Presets/BuiltInData.cs b/src/Filee.Core/Presets/BuiltInData.cs
index 1d93625b..e12dd414 100644
--- a/src/Filee.Core/Presets/BuiltInData.cs
+++ b/src/Filee.Core/Presets/BuiltInData.cs
@@ -65,17 +65,7 @@ public static class BuiltInData
Id = "pdf-split", NameKey = "preset.split_pdf", TargetFormat = "pdf",
Pdf = { SplitPages = true }, Output = { Location = OutputLocation.Subfolder, SubfolderName = "{name}" },
},
- new()
- {
- Id = "extract-frames-png", NameKey = "preset.extract_frames_png", TargetFormat = "png",
- Media = { SaveEveryFrame = true, FrameInterval = 1 },
- },
- new()
- {
- Id = "extract-frames-jpg", NameKey = "preset.extract_frames_jpg", TargetFormat = "jpg",
- Image = { Quality = 90 },
- Media = { SaveEveryFrame = true, FrameInterval = 1 },
- },
+ .. FramePresets(),
new() { Id = "to-docx", Name = "DOCX", TargetFormat = "docx" },
new() { Id = "to-hwpx", Name = "HWPX", TargetFormat = "hwpx" },
.. HwpPresets(),
@@ -92,6 +82,16 @@ public static class BuiltInData
.. TracePresets(),
];
+ /// <summary>
+ /// Every frame of a video as PNG or JPG pictures in a folder (added in settings schema 19), on no donut: a long
+ /// video gives thousands of files, so users add them in Settings → Toolbar.
+ /// </summary>
+ public static List<Preset> FramePresets() =>
+ [
+ new() { Id = "extract-frames-png", NameKey = "preset.extract_frames_png", TargetFormat = "png", Media = { SaveEveryFrame = true } },
+ new() { Id = "extract-frames-jpg", NameKey = "preset.extract_frames_jpg", TargetFormat = "jpg", Media = { SaveEveryFrame = true } },
+ ];
+
/// <summary>Raster → SVG tracing, in colour and as black line art (added in settings schema 16).</summary>
public static List<Preset> TracePresets() =>
[
diff --git a/src/Filee.Core/Settings/AppSettings.cs b/src/Filee.Core/Settings/AppSettings.cs
index ccda08f3..e003b8f9 100644
--- a/src/Filee.Core/Settings/AppSettings.cs
+++ b/src/Filee.Core/Settings/AppSettings.cs
@@ -50,7 +50,7 @@ public sealed class DonutSettings
public sealed class AppSettings
{
/// <summary>Current schema version. Increase when the format changes and add a migration.</summary>
- public const int CurrentSchemaVersion = 18;
+ public const int CurrentSchemaVersion = 19;
public int SchemaVersion { get; set; } = CurrentSchemaVersion;
diff --git a/src/Filee.Core/Settings/UserDataStore.cs b/src/Filee.Core/Settings/UserDataStore.cs
index cfae4bf6..f5bdb7fa 100644
--- a/src/Filee.Core/Settings/UserDataStore.cs
+++ b/src/Filee.Core/Settings/UserDataStore.cs
@@ -480,14 +480,17 @@ internal static class SettingsMigrations
}
}
- // v18: Video frame sequence extraction presets (PNG and JPG), on no donut to avoid accidental clicks.
- if (from < 18)
+ // v19: "Extract frames" (every frame of a video as PNG or JPG pictures in a folder), on no donut, after "Split
+ // PDF" as in a new library: a long video gives thousands of files, so users add them in Settings → Toolbar.
+ if (from < 19)
{
- foreach (var id in new[] { "extract-frames-png", "extract-frames-jpg" })
+ var at = presets.FindIndex(p => p.Id == "pdf-split");
+ at = at < 0 ? presets.Count : at + 1;
+ foreach (var preset in BuiltInData.FramePresets())
{
- if (presets.Any(p => p.Id == id))
+ if (presets.Any(p => p.Id == preset.Id))
continue;
- presets.Add(BuiltInData.CreatePresets().Single(p => p.Id == id));
+ presets.Insert(Math.Min(at++, presets.Count), preset);
changed = true;
}
}
diff --git a/tests/Filee.Core.Tests/UserDataStoreTests.cs b/tests/Filee.Core.Tests/UserDataStoreTests.cs
index 87b9fe98..ac59c9e4 100644
--- a/tests/Filee.Core.Tests/UserDataStoreTests.cs
+++ b/tests/Filee.Core.Tests/UserDataStoreTests.cs
@@ -303,13 +303,13 @@ public class UserDataStoreTests
}
[Fact]
- public void Version_17_libraries_get_the_extract_frames_presets()
+ public void Version_18_libraries_get_the_extract_frames_presets_after_split_pdf_on_no_donut()
{
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));
+ Assert.True(SettingsMigrations.ApplyToLibrary(18, presets, profiles));
var pngPreset = presets.Single(p => p.Id == "extract-frames-png");
Assert.True(pngPreset.Media.SaveEveryFrame);
@@ -319,9 +319,14 @@ public class UserDataStoreTests
Assert.True(jpgPreset.Media.SaveEveryFrame);
Assert.Equal("jpg", jpgPreset.TargetFormat);
+ // Where a new library has them.
+ Assert.Equal(BuiltInData.CreatePresets().Select(p => p.Id), presets.Select(p => p.Id));
+ var split = presets.FindIndex(p => p.Id == "pdf-split");
+ Assert.Equal(["extract-frames-png", "extract-frames-jpg"], presets.Skip(split + 1).Take(2).Select(p => p.Id));
+
Assert.DoesNotContain(profiles, p => p.PresetIds.Contains("extract-frames-png"));
Assert.DoesNotContain(profiles, p => p.PresetIds.Contains("extract-frames-jpg"));
- Assert.False(SettingsMigrations.ApplyToLibrary(17, presets, profiles)); // once only
+ Assert.False(SettingsMigrations.ApplyToLibrary(18, presets, profiles)); // once only
}
[Fact]