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
Crop: a 5:4 slice on the aspect dial, 4:5 on upright pictures (Instagram)
cre8ive-marketing311a00878c01
diff --git a/docs/ARCHITECTURE.md b/docs/ARCHITECTURE.mdindex abb52f53..90e50d27 100644--- a/docs/ARCHITECTURE.md+++ b/docs/ARCHITECTURE.md@@ -165,7 +165,7 @@ text, vectors, outlines, forms, page labels and document information remain PDF`CropService.LoadPreviewAsync`; nothing is decoded again while dragging. Programmatic changes (reset, a ratio, anew picture) ease in with tweens read against the clock, so a lost frame never leaves one half done; dragging andarrow-key nudges follow at once, and `PlayAnimations` (from `Motion.Enabled`) turns all of it off.-- `Controls/AspectDial` is a small donut of the ratios (free, original, 1:1, 4:3, 3:2, 16:9): each slice a+- `Controls/AspectDial` is a small donut of the ratios (free, original, 1:1, 5:4, 4:3, 3:2, 16:9): each slice a`RingSegment` button that answers only inside its wedge (`DonutGeometry.Wedge`, rounded by the softness), the hubswaps portrait and landscape. A with the pointer over the stage opens it around the pointer, as the donut opens,growing from its middle and kept inside the window; A without a pointer there (the keyboard) and its toolbar buttondiff --git a/src/Filee.App/Controls/AspectDial.cs b/src/Filee.App/Controls/AspectDial.csindex d4cd75e4..b7a17970 100644--- a/src/Filee.App/Controls/AspectDial.cs+++ b/src/Filee.App/Controls/AspectDial.cs@@ -1,5 +1,5 @@-// The crop overlay's aspect dial: a small donut whose slices are the ratios (free, the picture's own, 1:1, 4:3, 3:2,-// 16:9), each with a tiny outline of its shape, and a hub that swaps portrait and landscape. The slices are real+// The crop overlay's aspect dial: a small donut whose slices are the ratios (free, the picture's own, 1:1, 5:4, 4:3,+// 3:2, 16:9), each with a tiny outline of its shape, and a hub that swaps portrait and landscape. The slices are real// buttons (focus, keyboard, screen readers) that only answer inside their wedge. AspectGlyph is the dial in miniature// on the toolbar button that opens it.diff --git a/src/Filee.App/Controls/CropMath.cs b/src/Filee.App/Controls/CropMath.csindex 14f06064..b7bca2e4 100644--- a/src/Filee.App/Controls/CropMath.cs+++ b/src/Filee.App/Controls/CropMath.cs@@ -10,13 +10,13 @@ public static class CropMath/// <summary>The aspect dial's choices, clockwise from the top.</summary>public static IReadOnlyList<string> AspectModes => Modes;- private static readonly string[] Modes = ["free", "original", "1:1", "4:3", "3:2", "16:9"];+ private static readonly string[] Modes = ["free", "original", "1:1", "5:4", "4:3", "3:2", "16:9"];/// <summary>Where the mode sits on the dial, -1 for none.</summary>public static int AspectIndex(string mode) => Array.IndexOf(Modes, mode);/// <summary>A fixed ratio with a portrait and a landscape form (not free, the picture's own or square).</summary>- public static bool CanSwap(string mode) => mode is "4:3" or "3:2" or "16:9";+ public static bool CanSwap(string mode) => mode is "5:4" or "4:3" or "3:2" or "16:9";/// <summary>Width / height of the mode, 0 for free. Portrait turns a swappable ratio around (4:3 → 3:4).</summary>public static double Ratio(string mode, bool portrait, int originalWidth, int originalHeight)@@ -25,6 +25,7 @@ public static class CropMath{"original" => originalWidth > 0 && originalHeight > 0 ? (double)originalWidth / originalHeight : 0,"1:1" => 1.0,+ "5:4" => 5.0 / 4.0, // upright: 4:5, Instagram's portrait size (#542)"4:3" => 4.0 / 3.0,"3:2" => 3.0 / 2.0,"16:9" => 16.0 / 9.0,diff --git a/src/Filee.App/ViewModels/CropOverlayViewModel.cs b/src/Filee.App/ViewModels/CropOverlayViewModel.csindex cd2f8d7e..2ab53d48 100644--- a/src/Filee.App/ViewModels/CropOverlayViewModel.cs+++ b/src/Filee.App/ViewModels/CropOverlayViewModel.cs@@ -62,7 +62,7 @@ public sealed partial class CropOverlayViewModel : ObservableObject, IDisposable[NotifyPropertyChangedFor(nameof(IsAspectFree))]private string _selectedAspect = "free";- /// <summary>The fixed ratios (4:3, 3:2, 16:9) turned upright: 3:4, 2:3, 9:16.</summary>+ /// <summary>The fixed ratios (5:4, 4:3, 3:2, 16:9) turned upright: 4:5, 3:4, 2:3, 9:16.</summary>[ObservableProperty][NotifyPropertyChangedFor(nameof(AspectLabel))][NotifyPropertyChangedFor(nameof(AspectToolTip))]@@ -318,7 +318,7 @@ public sealed partial class CropOverlayViewModel : ObservableObject, IDisposableCloseRequested?.Invoke();}- /// <summary>Locks the frame to a ratio of the dial ("free", "original", "1:1", "4:3", "3:2", "16:9") and closes the dial.</summary>+ /// <summary>Locks the frame to a ratio of the dial ("free", "original", "1:1", "5:4", "4:3", "3:2", "16:9") and closes the dial.</summary>[RelayCommand]public void SetAspect(string mode){diff --git a/src/Filee.App/Views/CropOverlayWindow.axaml b/src/Filee.App/Views/CropOverlayWindow.axamlindex 22276d7d..4c8c86a7 100644--- a/src/Filee.App/Views/CropOverlayWindow.axaml+++ b/src/Filee.App/Views/CropOverlayWindow.axaml@@ -407,6 +407,7 @@<c:RingSegment Mode="free" Content="{DynamicResource crop.aspect_free}" Command="{Binding SetAspectCommand}" CommandParameter="free" /><c:RingSegment Mode="original" Content="{DynamicResource crop.aspect_original}" Command="{Binding SetAspectCommand}" CommandParameter="original" /><c:RingSegment Mode="1:1" Command="{Binding SetAspectCommand}" CommandParameter="1:1" />+ <c:RingSegment Mode="5:4" Command="{Binding SetAspectCommand}" CommandParameter="5:4" /><c:RingSegment Mode="4:3" Command="{Binding SetAspectCommand}" CommandParameter="4:3" /><c:RingSegment Mode="3:2" Command="{Binding SetAspectCommand}" CommandParameter="3:2" /><c:RingSegment Mode="16:9" Command="{Binding SetAspectCommand}" CommandParameter="16:9" />diff --git a/tests/Filee.App.Tests/CropMathTests.cs b/tests/Filee.App.Tests/CropMathTests.csindex 426d2ad0..7a021537 100644--- a/tests/Filee.App.Tests/CropMathTests.cs+++ b/tests/Filee.App.Tests/CropMathTests.cs@@ -11,6 +11,8 @@ public class CropMathTests[Theory][InlineData("free", false, 0.0)][InlineData("1:1", true, 1.0)]+ [InlineData("5:4", false, 5.0 / 4.0)]+ [InlineData("5:4", true, 4.0 / 5.0)] // Instagram's portrait size[InlineData("4:3", false, 4.0 / 3.0)][InlineData("4:3", true, 3.0 / 4.0)][InlineData("3:2", true, 2.0 / 3.0)]@@ -43,13 +45,14 @@ public class CropMathTests[Fact]public void Only_fixed_ratios_that_arent_square_swap(){- Assert.Equal(["4:3", "3:2", "16:9"], CropMath.AspectModes.Where(CropMath.CanSwap));+ Assert.Equal(["5:4", "4:3", "3:2", "16:9"], CropMath.AspectModes.Where(CropMath.CanSwap));+ Assert.Equal("4:5", CropMath.Numbers("5:4", portrait: true));Assert.Equal("9:16", CropMath.Numbers("16:9", portrait: true));Assert.Equal("16:9", CropMath.Numbers("16:9", portrait: false));Assert.Equal("1:1", CropMath.Numbers("1:1", portrait: true));Assert.Equal(0, CropMath.Ratio("original", false, 0, 0));- Assert.Equal(3, CropMath.AspectIndex("4:3"));- Assert.Equal(-1, CropMath.AspectIndex("5:4"));+ Assert.Equal(4, CropMath.AspectIndex("4:3"));+ Assert.Equal(-1, CropMath.AspectIndex("21:9"));}[Fact]diff --git a/tests/Filee.App.Tests/CropOverlayTests.cs b/tests/Filee.App.Tests/CropOverlayTests.csindex 52134aa6..31208d7f 100644--- a/tests/Filee.App.Tests/CropOverlayTests.cs+++ b/tests/Filee.App.Tests/CropOverlayTests.cs@@ -288,6 +288,25 @@ public class CropOverlayTests});}+ [AvaloniaFact]+ public void An_upright_picture_crops_at_instagrams_4_to_5_from_the_5_to_4_slice()+ {+ WithOverlay("en", false, ["tall.jpg"], (window, vm, _suffix) =>+ {+ Settle(window);+ var slice = window.AspectDial.Segments.Single(s => s.Mode == "5:4");+ slice.Command!.Execute(slice.CommandParameter);+ Settle(window);+ Assert.Equal("4:5", vm.AspectLabel);+ Assert.Equal(0.8, window.CropCanvas.AspectRatio, 6);+ var frame = window.CropCanvas.NormalizedCropRect;+ Assert.Equal(0.8, frame.Width * 1000 / (frame.Height * 1600), 2);+ vm.ToggleAspectDial();+ Settle(window);+ RenderTests.Save(window, "crop-dial-4-5.png");+ });+ }+[AvaloniaFact]public void The_next_file_starts_free_and_full_in_view_and_canvas_alike(){