diff --git a/src/ImageSharp/Common/Helpers/UnitConverter.cs b/src/ImageSharp/Common/Helpers/UnitConverter.cs
index 9a7d25c559..c8b25bf564 100644
--- a/src/ImageSharp/Common/Helpers/UnitConverter.cs
+++ b/src/ImageSharp/Common/Helpers/UnitConverter.cs
@@ -1,7 +1,6 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
-using System;
using System.Runtime.CompilerServices;
using SixLabors.ImageSharp.MetaData;
using SixLabors.ImageSharp.MetaData.Profiles.Exif;
@@ -19,6 +18,12 @@ namespace SixLabors.ImageSharp.Common.Helpers
///
private const double CmsInMeter = 1 / 0.01D;
+ ///
+ /// The number of centimeters in an inch.
+ /// 1 inch is equal to exactly 2.54 centimeters.
+ ///
+ private const double CmsInInch = 2.54D;
+
///
/// The number of inches in a meter.
/// 1 inch is equal to exactly 0.0254 meters.
@@ -57,6 +62,22 @@ namespace SixLabors.ImageSharp.Common.Helpers
[MethodImpl(InliningOptions.ShortMethod)]
public static double InchToMeter(double x) => x * InchesInMeter;
+ ///
+ /// Scales the value from centimeters to inches.
+ ///
+ /// The value to scale.
+ /// The .
+ [MethodImpl(InliningOptions.ShortMethod)]
+ public static double CmToInch(double x) => x / CmsInInch;
+
+ ///
+ /// Scales the value from inches to centimeters.
+ ///
+ /// The value to scale.
+ /// The .
+ [MethodImpl(InliningOptions.ShortMethod)]
+ public static double InchToCm(double x) => x * CmsInInch;
+
///
/// Converts an to a .
///
diff --git a/tests/ImageSharp.Tests/Helpers/UnitConverterHelperTests.cs b/tests/ImageSharp.Tests/Helpers/UnitConverterHelperTests.cs
new file mode 100644
index 0000000000..57e280d938
--- /dev/null
+++ b/tests/ImageSharp.Tests/Helpers/UnitConverterHelperTests.cs
@@ -0,0 +1,41 @@
+// Copyright (c) Six Labors and contributors.
+// Licensed under the Apache License, Version 2.0.
+
+using SixLabors.ImageSharp.Common.Helpers;
+using Xunit;
+
+namespace SixLabors.ImageSharp.Tests.Helpers
+{
+ public class UnitConverterHelperTests
+ {
+ [Fact]
+ public void InchToFromMeter()
+ {
+ const double expected = 96D;
+ double actual = UnitConverter.InchToMeter(expected);
+ actual = UnitConverter.MeterToInch(actual);
+
+ Assert.Equal(expected, actual, 15);
+ }
+
+ [Fact]
+ public void InchToFromCm()
+ {
+ const double expected = 96D;
+ double actual = UnitConverter.InchToCm(expected);
+ actual = UnitConverter.CmToInch(actual);
+
+ Assert.Equal(expected, actual, 15);
+ }
+
+ [Fact]
+ public void CmToFromMeter()
+ {
+ const double expected = 96D;
+ double actual = UnitConverter.CmToMeter(expected);
+ actual = UnitConverter.MeterToCm(actual);
+
+ Assert.Equal(expected, actual, 15);
+ }
+ }
+}