< Summary

Information
Class: Anichron.Core.Domain.ExifOrientation
Assembly: Anichron.Core
File(s): /home/runner/work/anichron/anichron/src/Anichron.Core/Domain/ExifOrientation.cs
Tag: 19_45211875487
Line coverage
100%
Covered lines: 8
Uncovered lines: 0
Coverable lines: 8
Total lines: 30
Line coverage: 100%
Branch coverage
100%
Covered branches: 8
Total branches: 8
Branch coverage: 100%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
SwapsAxes(...)100%22100%
OfDisplayRotation(...)100%66100%

File(s)

/home/runner/work/anichron/anichron/src/Anichron.Core/Domain/ExifOrientation.cs

#LineLine coverage
 1namespace Anichron.Core.Domain;
 2
 3public static class ExifOrientation
 4{
 5    public const int Upright = 1;
 6    public const int RotateHalfTurn = 3;
 7    public const int RotateClockwise = 6;
 8    public const int RotateAnticlockwise = 8;
 9    public const int Max = 8;
 10
 11    /// <summary>
 12    /// Whether the orientation includes a quarter turn (EXIF 5-8), so the upright image's width is the stored height.
 13    /// </summary>
 14    /// <param name="orientation">The EXIF orientation value, 1-8.</param>
 3515    public static bool SwapsAxes(int orientation) => orientation is >= 5 and <= Max;
 16
 17    /// <summary>
 18    /// The orientation that shows stored pixels as a display rotation does (a HEIF <c>irot</c>, a QuickTime
 19    /// track's rotation); a rotation that is not a multiple of 90 degrees is upright.
 20    /// </summary>
 21    /// <param name="degrees">The display rotation, anticlockwise.</param>
 22    public static int OfDisplayRotation(double degrees)
 3523        => ((((int)Math.Round(degrees) % 360) + 360) % 360) switch
 3524        {
 525            90 => RotateAnticlockwise,
 526            180 => RotateHalfTurn,
 827            270 => RotateClockwise,
 1728            _ => Upright,
 3529        };
 30}