diff --git a/Program.cs b/Program.cs index 36c7220..319157a 100644 --- a/Program.cs +++ b/Program.cs @@ -386,12 +386,20 @@ public static class Util { // https://sirv.com/help/articles/rotate-photos-to-be-upright/ public static void RotateImageFromExif(Image image, ushort orientation) { - if (orientation == 1) { + if (orientation <= 1) { return; } - if (orientation == 8) { - image.Mutate(x => x.RotateFlip(RotateMode.Rotate270, FlipMode.None)); - } + var operations = new Dictionary { + { 2, (RotateMode.None, FlipMode.Horizontal) }, + { 3, (RotateMode.Rotate180, FlipMode.None) }, + { 4, (RotateMode.Rotate180, FlipMode.Horizontal) }, + { 5, (RotateMode.Rotate90, FlipMode.Vertical) }, + { 6, (RotateMode.Rotate90, FlipMode.None) }, + { 7, (RotateMode.Rotate270, FlipMode.Vertical) }, + { 8, (RotateMode.Rotate270, FlipMode.None) }, + }; + var (rotate, flip) = operations[orientation]; + image.Mutate(x => x.RotateFlip(rotate, flip)); } public static Texture RenderText(string text) {