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
Rotate and flip in the preset editor
SeoJCalive2d4efcc27676
diff --git a/src/Filee.App/Assets/i18n/en.json b/src/Filee.App/Assets/i18n/en.jsonindex 59e474c3..d4b0be2c 100644--- a/src/Filee.App/Assets/i18n/en.json+++ b/src/Filee.App/Assets/i18n/en.json@@ -320,6 +320,15 @@"presets.resize.Percent": "Scale by percent","presets.resize.LongEdge": "Limit the long edge","presets.resize.Width": "Set the width",+ "presets.rotation": "Rotate",+ "presets.rotation.None": "Don't rotate",+ "presets.rotation.Right90": "Right 90°",+ "presets.rotation.Left90": "Left 90°",+ "presets.rotation.Rotate180": "180°",+ "presets.flip": "Flip",+ "presets.flip.None": "Don't flip",+ "presets.flip.Horizontal": "Left ↔ right",+ "presets.flip.Vertical": "Top ↔ bottom","presets.percent": "Percent","presets.long_edge": "Long edge (px)","presets.width": "Width (px)",diff --git a/src/Filee.App/Assets/i18n/ko.json b/src/Filee.App/Assets/i18n/ko.jsonindex cbeaca32..c0721493 100644--- a/src/Filee.App/Assets/i18n/ko.json+++ b/src/Filee.App/Assets/i18n/ko.json@@ -320,6 +320,15 @@"presets.resize.Percent": "비율로 조정","presets.resize.LongEdge": "긴 변 제한","presets.resize.Width": "너비 맞추기",+ "presets.rotation": "회전",+ "presets.rotation.None": "회전 안 함",+ "presets.rotation.Right90": "오른쪽 90°",+ "presets.rotation.Left90": "왼쪽 90°",+ "presets.rotation.Rotate180": "180°",+ "presets.flip": "반전",+ "presets.flip.None": "반전 안 함",+ "presets.flip.Horizontal": "좌우 반전",+ "presets.flip.Vertical": "상하 반전","presets.percent": "비율 (%)","presets.long_edge": "긴 변 (px)","presets.width": "너비(px)",diff --git a/src/Filee.App/Assets/i18n/zh-CN.json b/src/Filee.App/Assets/i18n/zh-CN.jsonindex b251349c..2d411b26 100644--- a/src/Filee.App/Assets/i18n/zh-CN.json+++ b/src/Filee.App/Assets/i18n/zh-CN.json@@ -320,6 +320,15 @@"presets.resize.Percent": "按百分比缩放","presets.resize.LongEdge": "限制长边","presets.resize.Width": "设置宽度",+ "presets.rotation": "旋转",+ "presets.rotation.None": "不旋转",+ "presets.rotation.Right90": "向右 90°",+ "presets.rotation.Left90": "向左 90°",+ "presets.rotation.Rotate180": "180°",+ "presets.flip": "翻转",+ "presets.flip.None": "不翻转",+ "presets.flip.Horizontal": "水平翻转",+ "presets.flip.Vertical": "垂直翻转","presets.percent": "百分比","presets.long_edge": "长边 (px)","presets.width": "宽度(像素)",diff --git a/src/Filee.App/ViewModels/PresetEditorViewModel.cs b/src/Filee.App/ViewModels/PresetEditorViewModel.csindex b608376d..cb6a0e3f 100644--- a/src/Filee.App/ViewModels/PresetEditorViewModel.cs+++ b/src/Filee.App/ViewModels/PresetEditorViewModel.cs@@ -60,6 +60,8 @@ public sealed partial class PresetEditorViewModel : ObservableObjectFormatLabels.Category(loc, f.Category))),];ResizeModes = Enum.GetValues<ResizeMode>().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();PageSizes = Enum.GetValues<PdfPageSize>().Select(v => new Choice<PdfPageSize>(v, loc[$"presets.page_size.{v}"])).ToList();Locations = Enum.GetValues<OutputLocation>().Select(v => new Choice<OutputLocation>(v, loc[$"presets.location.{v}"])).ToList();Conflicts = Enum.GetValues<ConflictPolicy>().Select(v => new Choice<ConflictPolicy>(v, loc[$"presets.conflict.{v}"])).ToList();@@ -76,6 +78,8 @@ public sealed partial class PresetEditorViewModel : ObservableObject_name = string.IsNullOrWhiteSpace(_edit.Name) ? loc.DisplayName(_edit) : _edit.Name;_target = Targets.FirstOrDefault(t => t.Value == _edit.TargetFormat) ?? Targets[1];_resize = ResizeModes.First(r => r.Value == _edit.Image.Resize);+ _rotation = Rotations.First(r => r.Value == _edit.Image.Rotation);+ _flip = Flips.First(f => f.Value == _edit.Image.Flip);_pageSize = PageSizes.First(p => p.Value == _edit.Pdf.PageSize);_location = Locations.First(l => l.Value == _edit.Output.Location);_conflict = Conflicts.First(c => c.Value == _edit.Output.Conflict);@@ -124,6 +128,10 @@ public sealed partial class PresetEditorViewModel : ObservableObjectpublic IReadOnlyList<Choice<string>> Targets { get; }public IReadOnlyList<Choice<ResizeMode>> ResizeModes { get; }++ /// <summary>Turning and mirroring: what the built-in rotate / flip presets do, for any image preset.</summary>+ public IReadOnlyList<Choice<ImageRotation>> Rotations { get; }+ public IReadOnlyList<Choice<ImageFlip>> Flips { get; }public IReadOnlyList<Choice<PdfPageSize>> PageSizes { get; }public IReadOnlyList<Choice<OutputLocation>> Locations { get; }public IReadOnlyList<Choice<ConflictPolicy>> Conflicts { get; }@@ -150,6 +158,9 @@ public sealed partial class PresetEditorViewModel : ObservableObject[ObservableProperty, NotifyPropertyChangedFor(nameof(ShowPercent), nameof(ShowLongEdge), nameof(ShowWidth))]private Choice<ResizeMode> _resize;+ [ObservableProperty] private Choice<ImageRotation> _rotation;+ [ObservableProperty] private Choice<ImageFlip> _flip;+[ObservableProperty, NotifyPropertyChangedFor(nameof(ShowMargin))]private Choice<PdfPageSize> _pageSize;@@ -277,6 +288,8 @@ public sealed partial class PresetEditorViewModel : ObservableObjectvar image = _original.Image;image.Quality = Math.Clamp(Quality, 1, 100);image.Resize = Resize.Value;+ image.Rotation = Rotation.Value;+ image.Flip = Flip.Value;image.ResizePercent = Math.Clamp(ResizePercent, 1, 1000);image.LongEdge = Math.Clamp(LongEdge, 16, 20000);image.Width = Math.Clamp(Width, 16, 20000);diff --git a/src/Filee.App/Views/PresetEditorView.axaml b/src/Filee.App/Views/PresetEditorView.axamlindex 4f6ae7b9..d85696b2 100644--- a/src/Filee.App/Views/PresetEditorView.axaml+++ b/src/Filee.App/Views/PresetEditorView.axaml@@ -66,6 +66,16 @@<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}" />diff --git a/tests/Filee.App.Tests/RenderTests.cs b/tests/Filee.App.Tests/RenderTests.csindex f70c09db..d603adb3 100644--- a/tests/Filee.App.Tests/RenderTests.cs+++ b/tests/Filee.App.Tests/RenderTests.cs@@ -542,6 +542,30 @@ public class RenderTestswindow.Close();}+ [AvaloniaFact]+ public void Preset_editor_shows_and_saves_rotation_and_flip()+ {+ TestServices.EnsureInitialized("ko");+ var preset = Filee.Core.Presets.BuiltInData.CreatePresets().Single(p => p.Id == "rotate-left");+ var vm = new PresetEditorViewModel(preset, AppHost.Get<Filee.Core.Localization.ILocalizer>());+ Assert.Equal(Filee.Core.Presets.ImageRotation.Left90, vm.Rotation.Value); // not a hidden option any more+ Assert.Equal(Filee.Core.Presets.ImageFlip.None, vm.Flip.Value);+ var window = new PresetEditorWindow { DataContext = vm, Height = 900 };+ window.Show();+ Pump();+ Save(window, "preset-rotate-ko.png");+ window.Close();++ // Rotate and convert in one: turn left, mirror, and make it a JPG.+ vm.Flip = vm.Flips.Single(f => f.Value == Filee.Core.Presets.ImageFlip.Horizontal);+ vm.Target = vm.Targets.Single(t => t.Value == "jpg");+ Assert.True(vm.Apply());++ Assert.Equal(Filee.Core.Presets.ImageRotation.Left90, preset.Image.Rotation);+ Assert.Equal(Filee.Core.Presets.ImageFlip.Horizontal, preset.Image.Flip);+ Assert.Equal("jpg", preset.TargetFormat);+ }+[AvaloniaFact]public void Preset_editor_shows_and_saves_background_removal(){