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.

Merge remote-tracking branch 'upstream/main' into feature/interactive-crop-and-donut-paging

smjriflebc74b59779be
diff --cc src/Filee.App/ViewModels/PresetEditorViewModel.cs
index a0bbf07e,38bfca6c..2794f93c
--- a/src/Filee.App/ViewModels/PresetEditorViewModel.cs
+++ b/src/Filee.App/ViewModels/PresetEditorViewModel.cs
@@@ -428,8 -435,13 +438,13 @@@ public sealed partial class PresetEdito
/// <summary>"Extract" has nothing to set; a line says what it does instead.</summary>
public bool ShowExtractNote => TargetId == FormatRegistry.Folder;
/// <summary>"Save every frame" of a video: PNG and JPG (format ids, <see cref="MediaOptions.FrameTargets"/>).</summary>
- public bool ShowSaveEveryFrame => MediaOptions.FrameTargets.Contains(TargetId);
+ public bool ShowSaveEveryFrame => !IsTool && MediaOptions.FrameTargets.Contains(TargetId);
/// <summary>
+ /// Playback speed: for the formats an animation stays animated in (an animated GIF, WebP, APNG or MNG, or a video
+ /// made into a GIF or APNG). Other targets get one frame.
+ /// </summary>
+ public bool ShowAnimationSpeed => TargetId is "gif" or "webp" or "apng" or "mng" or BuiltInData.SameAsSource;
+ /// <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>
diff --cc src/Filee.App/Views/PresetEditorView.axaml
index 657da87d,f09800a2..824c4934
--- a/src/Filee.App/Views/PresetEditorView.axaml
+++ b/src/Filee.App/Views/PresetEditorView.axaml
@@@ -49,75 -48,80 +49,82 @@@
</DockPanel>
<Slider Minimum="1" Maximum="100" Value="{Binding Quality}" TickFrequency="1" IsSnapToTickEnabled="True" />
</StackPanel>
- <Grid ColumnDefinitions="*,12,*">
- <StackPanel>
- <TextBlock Classes="label" Text="{DynamicResource presets.resize}" />
- <ComboBox ItemsSource="{Binding ResizeModes}" SelectedItem="{Binding Resize}" HorizontalAlignment="Stretch" />
+ <StackPanel Spacing="10" IsVisible="{Binding ShowImageTools}">
+ <Grid ColumnDefinitions="*,12,*">
+ <StackPanel>
+ <TextBlock Classes="label" Text="{DynamicResource presets.resize}" />
+ <ComboBox ItemsSource="{Binding ResizeModes}" SelectedItem="{Binding Resize}" HorizontalAlignment="Stretch" />
+ </StackPanel>
+ <StackPanel Grid.Column="2" IsVisible="{Binding ShowPercent}">
+ <TextBlock Classes="label" Text="{DynamicResource presets.percent}" />
+ <NumericUpDown Value="{Binding ResizePercent}" Minimum="1" Maximum="1000" Increment="5" FormatString="0" />
+ </StackPanel>
+ <StackPanel Grid.Column="2" IsVisible="{Binding ShowLongEdge}">
+ <TextBlock Classes="label" Text="{DynamicResource presets.long_edge}" />
+ <NumericUpDown Value="{Binding LongEdge}" Minimum="16" Maximum="20000" Increment="100" FormatString="0" />
+ </StackPanel>
+ <StackPanel Grid.Column="2" IsVisible="{Binding ShowWidth}">
+ <TextBlock Classes="label" Text="{DynamicResource presets.width}" />
+ <NumericUpDown Value="{Binding Width}" Minimum="16" Maximum="20000" Increment="100" FormatString="0" />
+ </StackPanel>
+ </Grid>
+ <Grid ColumnDefinitions="*,12,*">
+ <StackPanel>
+ <TextBlock Classes="label" Text="{DynamicResource presets.rotation}" />
+ <ComboBox ItemsSource="{Binding Rotations}" SelectedItem="{Binding Rotation}" HorizontalAlignment="Stretch" />
+ </StackPanel>
+ <StackPanel Grid.Column="2">
+ <TextBlock Classes="label" Text="{DynamicResource presets.flip}" />
+ <ComboBox ItemsSource="{Binding Flips}" SelectedItem="{Binding Flip}" HorizontalAlignment="Stretch" />
+ </StackPanel>
+ </Grid>
+ <Grid ColumnDefinitions="Auto,12,*">
+ <CheckBox Content="{DynamicResource presets.dpi}" IsChecked="{Binding SetDpi}" />
+ <NumericUpDown Grid.Column="2" Value="{Binding Dpi}" Minimum="36" Maximum="2400" Increment="50" FormatString="0" IsEnabled="{Binding SetDpi}" />
+ </Grid>
+ <WrapPanel>
+ <CheckBox Content="{DynamicResource presets.keep_metadata}" IsChecked="{Binding KeepMetadata}" Margin="0,0,18,0" />
+ <CheckBox Content="{DynamicResource presets.keep_color_profile}" IsChecked="{Binding ColorProfileChecked}"
+ IsEnabled="{Binding CanChangeColorProfile}" ToolTip.Tip="{DynamicResource presets.keep_color_profile_hint}" ToolTip.ShowOnDisabled="True" Margin="0,0,18,0" />
+ <CheckBox Content="{DynamicResource presets.grayscale}" IsChecked="{Binding Grayscale}" Margin="0,0,18,0" />
+ <CheckBox Content="{DynamicResource presets.webp_lossless}" IsChecked="{Binding WebpLossless}" IsVisible="{Binding ShowWebp}" />
+ </WrapPanel>
+ <CheckBox Content="{DynamicResource presets.remove_background}" IsChecked="{Binding RemoveBackground}"
+ ToolTip.Tip="{DynamicResource presets.remove_background_hint}" />
+ <StackPanel Spacing="6" IsVisible="{Binding RemoveBackground}">
+ <DockPanel>
+ <TextBlock DockPanel.Dock="Right" Text="{Binding BackgroundTolerance}" FontWeight="SemiBold" />
+ <TextBlock Classes="label" Text="{DynamicResource presets.background_tolerance}" />
+ </DockPanel>
+ <Slider Minimum="0" Maximum="100" Value="{Binding BackgroundTolerance}" TickFrequency="1" IsSnapToTickEnabled="True"
+ ToolTip.Tip="{DynamicResource presets.background_tolerance_hint}" />
+ <CheckBox Content="{DynamicResource presets.keep_enclosed_background}" IsChecked="{Binding KeepEnclosedBackground}"
+ ToolTip.Tip="{DynamicResource presets.keep_enclosed_background_hint}" />
</StackPanel>
- <StackPanel Grid.Column="2" IsVisible="{Binding ShowPercent}">
- <TextBlock Classes="label" Text="{DynamicResource presets.percent}" />
- <NumericUpDown Value="{Binding ResizePercent}" Minimum="1" Maximum="1000" Increment="5" FormatString="0" />
- </StackPanel>
- <StackPanel Grid.Column="2" IsVisible="{Binding ShowLongEdge}">
- <TextBlock Classes="label" Text="{DynamicResource presets.long_edge}" />
- <NumericUpDown Value="{Binding LongEdge}" Minimum="16" Maximum="20000" Increment="100" FormatString="0" />
- </StackPanel>
- <StackPanel Grid.Column="2" IsVisible="{Binding ShowWidth}">
- <TextBlock Classes="label" Text="{DynamicResource presets.width}" />
- <NumericUpDown Value="{Binding Width}" Minimum="16" Maximum="20000" Increment="100" FormatString="0" />
- </StackPanel>
- </Grid>
- <Grid ColumnDefinitions="*,12,*">
- <StackPanel>
- <TextBlock Classes="label" Text="{DynamicResource presets.rotation}" />
- <ComboBox ItemsSource="{Binding Rotations}" SelectedItem="{Binding Rotation}" HorizontalAlignment="Stretch" />
- </StackPanel>
- <StackPanel Grid.Column="2">
- <TextBlock Classes="label" Text="{DynamicResource presets.flip}" />
- <ComboBox ItemsSource="{Binding Flips}" SelectedItem="{Binding Flip}" HorizontalAlignment="Stretch" />
- </StackPanel>
- </Grid>
- <Grid ColumnDefinitions="Auto,12,*">
- <CheckBox Content="{DynamicResource presets.dpi}" IsChecked="{Binding SetDpi}" />
- <NumericUpDown Grid.Column="2" Value="{Binding Dpi}" Minimum="36" Maximum="2400" Increment="50" FormatString="0" IsEnabled="{Binding SetDpi}" />
- </Grid>
- <WrapPanel>
- <CheckBox Content="{DynamicResource presets.keep_metadata}" IsChecked="{Binding KeepMetadata}" Margin="0,0,18,0" />
- <CheckBox Content="{DynamicResource presets.keep_color_profile}" IsChecked="{Binding ColorProfileChecked}"
- IsEnabled="{Binding CanChangeColorProfile}" ToolTip.Tip="{DynamicResource presets.keep_color_profile_hint}" ToolTip.ShowOnDisabled="True" Margin="0,0,18,0" />
- <CheckBox Content="{DynamicResource presets.grayscale}" IsChecked="{Binding Grayscale}" Margin="0,0,18,0" />
- <CheckBox Content="{DynamicResource presets.webp_lossless}" IsChecked="{Binding WebpLossless}" IsVisible="{Binding ShowWebp}" />
- </WrapPanel>
- <CheckBox Content="{DynamicResource presets.remove_background}" IsChecked="{Binding RemoveBackground}"
- ToolTip.Tip="{DynamicResource presets.remove_background_hint}" />
- <StackPanel Spacing="6" IsVisible="{Binding RemoveBackground}">
- <DockPanel>
- <TextBlock DockPanel.Dock="Right" Text="{Binding BackgroundTolerance}" FontWeight="SemiBold" />
- <TextBlock Classes="label" Text="{DynamicResource presets.background_tolerance}" />
- </DockPanel>
- <Slider Minimum="0" Maximum="100" Value="{Binding BackgroundTolerance}" TickFrequency="1" IsSnapToTickEnabled="True"
- ToolTip.Tip="{DynamicResource presets.background_tolerance_hint}" />
- <CheckBox Content="{DynamicResource presets.keep_enclosed_background}" IsChecked="{Binding KeepEnclosedBackground}"
- ToolTip.Tip="{DynamicResource presets.keep_enclosed_background_hint}" />
+ <Grid ColumnDefinitions="*,12,*">
+ <StackPanel>
+ <TextBlock Classes="label" Text="{DynamicResource presets.background}" />
+ <TextBox Text="{Binding Background}" PlaceholderText="#FFFFFF" />
+ </StackPanel>
+ <StackPanel Grid.Column="2" IsVisible="{Binding ShowTiff}">
+ <TextBlock Classes="label" Text="{DynamicResource presets.tiff_compression}" />
+ <ComboBox ItemsSource="{Binding TiffCompressions}" SelectedItem="{Binding TiffCompression}" HorizontalAlignment="Stretch" />
+ </StackPanel>
+ <StackPanel Grid.Column="2" IsVisible="{Binding ShowIco}">
+ <TextBlock Classes="label" Text="{DynamicResource presets.ico_sizes}" />
+ <TextBox Text="{Binding IcoSizes}" PlaceholderText="256, 64, 48, 32, 16" />
+ </StackPanel>
+ </Grid>
++ <Grid ColumnDefinitions="*,12,*" IsVisible="{Binding ShowAnimationSpeed}">
++ <StackPanel>
++ <TextBlock Classes="label" Text="{DynamicResource presets.animation_speed}" />
++ <ComboBox ItemsSource="{Binding AnimationSpeeds}" SelectedItem="{Binding AnimationSpeed}" HorizontalAlignment="Stretch"
++ ToolTip.Tip="{DynamicResource presets.animation_speed_hint}" />
++ </StackPanel>
++ </Grid>
+ <CheckBox Content="{DynamicResource presets.multipage_tiff}" IsChecked="{Binding MultiPageTiff}" IsVisible="{Binding ShowMultiPageTiff}"
+ ToolTip.Tip="{DynamicResource presets.multipage_tiff_hint}" />
</StackPanel>
- <Grid ColumnDefinitions="*,12,*">
- <StackPanel>
- <TextBlock Classes="label" Text="{DynamicResource presets.background}" />
- <TextBox Text="{Binding Background}" PlaceholderText="#FFFFFF" />
- </StackPanel>
- <StackPanel Grid.Column="2" IsVisible="{Binding ShowTiff}">
- <TextBlock Classes="label" Text="{DynamicResource presets.tiff_compression}" />
- <ComboBox ItemsSource="{Binding TiffCompressions}" SelectedItem="{Binding TiffCompression}" HorizontalAlignment="Stretch" />
- </StackPanel>
- <StackPanel Grid.Column="2" IsVisible="{Binding ShowIco}">
- <TextBlock Classes="label" Text="{DynamicResource presets.ico_sizes}" />
- <TextBox Text="{Binding IcoSizes}" PlaceholderText="256, 64, 48, 32, 16" />
- </StackPanel>
- </Grid>
- <Grid ColumnDefinitions="*,12,*" IsVisible="{Binding ShowAnimationSpeed}">
- <StackPanel>
- <TextBlock Classes="label" Text="{DynamicResource presets.animation_speed}" />
- <ComboBox ItemsSource="{Binding AnimationSpeeds}" SelectedItem="{Binding AnimationSpeed}" HorizontalAlignment="Stretch"
- ToolTip.Tip="{DynamicResource presets.animation_speed_hint}" />
- </StackPanel>
- </Grid>
- <CheckBox Content="{DynamicResource presets.multipage_tiff}" IsChecked="{Binding MultiPageTiff}" IsVisible="{Binding ShowMultiPageTiff}"
- ToolTip.Tip="{DynamicResource presets.multipage_tiff_hint}" />
<StackPanel Spacing="6" IsVisible="{Binding ShowSaveEveryFrame}">
<CheckBox Content="{DynamicResource presets.save_every_frame}" IsChecked="{Binding SaveEveryFrame}"
ToolTip.Tip="{DynamicResource presets.save_every_frame_hint}" />
diff --cc src/Filee.Core/Settings/AppSettings.cs
index f55d3200,f1d77877..7ec34b1d
--- a/src/Filee.Core/Settings/AppSettings.cs
+++ b/src/Filee.Core/Settings/AppSettings.cs
@@@ -64,7 -64,7 +64,7 @@@ public sealed class DonutSetting
public sealed class AppSettings
{
/// <summary>Current schema version. Increase when the format changes and add a migration.</summary>
- public const int CurrentSchemaVersion = 21;
- public const int CurrentSchemaVersion = 22;
++ public const int CurrentSchemaVersion = 23;
public int SchemaVersion { get; set; } = CurrentSchemaVersion;
diff --cc src/Filee.Core/Settings/UserDataStore.cs
index bcd92528,72d44f90..032bd586
--- a/src/Filee.Core/Settings/UserDataStore.cs
+++ b/src/Filee.Core/Settings/UserDataStore.cs
@@@ -549,30 -555,14 +555,38 @@@ internal static class SettingsMigration
changed = true;
}
}
-
- // v21: interactive "Crop" tool, after "Remove background" as in a new library, on no donut: users add it in
- // Settings → Toolbar. Present already but saved since by a Filee before 21: that one read the unknown
+ // v21: JPEG XR (.jxr, .wdp, .hdp; HDR screenshots of Windows): the images donut learns the extensions unless
+ // another donut already has them.
+ if (from < 21)
+ changed |= LearnExtensions(profiles, out _, ["jxr", "wdp", "hdp"]);
+ // v22: FBX models (read only) open from the 3D donut: it learns ".fbx" unless a donut of the user already
+ // takes it. Other extensions the user removed from a built-in donut stay removed.
+ if (from < 22)
+ changed |= LearnExtensions(profiles, out _, ["fbx"]);
++
++ // v23: interactive "Crop" tool, after "Remove background" as in a new library, on no donut: users add it in
++ // Settings → Toolbar. Present already but saved since by a Filee before 23: that one read the unknown
+ // kind as a Group, dropped the target format and left an empty group. Kind and target format are put back,
+ // the user's own changes (name, file name pattern) stay.
- if (from < 21)
++ if (from < 23)
+ {
+ if (BuiltInData.CreatePresets().FirstOrDefault(p => p.Id == "tool-crop") is { } crop)
+ {
+ if (presets.FirstOrDefault(p => p.Id == "tool-crop") is not { } existing)
+ {
+ var at = presets.FindIndex(p => p.Id == "remove-background");
+ presets.Insert(at < 0 ? presets.Count : at + 1, crop);
+ changed = true;
+ }
+ else if (existing.Kind != PresetKind.Tool)
+ {
+ existing.Kind = PresetKind.Tool;
+ existing.TargetFormat = crop.TargetFormat;
+ existing.SubPresetIds = [];
+ changed = true;
+ }
+ }
+ }
return changed;
}
diff --cc tests/Filee.Core.Tests/UserDataStoreTests.cs
index 08a84db6,42c55c56..80fc8ec6
--- a/tests/Filee.Core.Tests/UserDataStoreTests.cs
+++ b/tests/Filee.Core.Tests/UserDataStoreTests.cs
@@@ -731,42 -819,6 +819,42 @@@ public class UserDataStoreTest
Assert.False(SettingsMigrations.ApplyToLibrary(17, presets, profiles)); // once only
}
+ [Fact]
- public void Version_20_libraries_get_crop_tool_preset_after_remove_background_on_no_donut()
++ public void Version_22_libraries_get_crop_tool_preset_after_remove_background_on_no_donut()
+ {
+ var presets = BuiltInData.CreatePresets();
+ presets.RemoveAll(p => p.Id == "tool-crop");
+ var profiles = BuiltInData.CreateProfiles();
+
- Assert.True(SettingsMigrations.ApplyToLibrary(20, presets, profiles));
++ Assert.True(SettingsMigrations.ApplyToLibrary(22, presets, profiles));
+
+ var crop = presets.Single(p => p.Id == "tool-crop");
+ Assert.Equal(PresetKind.Tool, crop.Kind);
+ Assert.Equal("remove-background", presets[presets.IndexOf(crop) - 1].Id);
+ Assert.DoesNotContain(profiles, p => p.PresetIds.Contains("tool-crop"));
- Assert.False(SettingsMigrations.ApplyToLibrary(20, presets, profiles)); // once only
++ Assert.False(SettingsMigrations.ApplyToLibrary(22, presets, profiles)); // once only
+ }
+
+ [Fact]
+ public void Back_from_an_older_Filee_tool_crop_works_again_and_keeps_the_users_changes()
+ {
- // What a Filee before 21 leaves after saving: kind read as Group, TargetFormat dropped, SubPresetIds empty, the rest as it was.
++ // What a Filee before 23 leaves after saving: kind read as Group, TargetFormat dropped, SubPresetIds empty, the rest as it was.
+ var presets = BuiltInData.CreatePresets();
+ var crop = presets.Single(p => p.Id == "tool-crop");
+ crop.Kind = PresetKind.Group;
+ crop.TargetFormat = Preset.GroupTarget;
+ crop.SubPresetIds = [];
+ crop.Name = "Trim";
+
- Assert.True(SettingsMigrations.ApplyToLibrary(20, presets, BuiltInData.CreateProfiles()));
++ Assert.True(SettingsMigrations.ApplyToLibrary(22, presets, BuiltInData.CreateProfiles()));
+
+ Assert.Equal(PresetKind.Tool, crop.Kind);
+ Assert.Equal(BuiltInData.SameAsSource, crop.TargetFormat);
+ Assert.Empty(crop.SubPresetIds);
+ Assert.Equal("Trim", crop.Name);
+ Assert.Single(presets, p => p.Id == "tool-crop");
+ }
+
[Fact]
public void Back_from_an_older_Filee_compress_pdf_compresses_again_and_keeps_the_users_changes()
{