diff --git a/src/ImageProcessorCore/Profiles/Exif/ExifTag.cs b/src/ImageProcessorCore/Profiles/Exif/ExifTag.cs
index 944a2a15ad..b7318dfc40 100644
--- a/src/ImageProcessorCore/Profiles/Exif/ExifTag.cs
+++ b/src/ImageProcessorCore/Profiles/Exif/ExifTag.cs
@@ -159,6 +159,9 @@ namespace ImageProcessorCore
///
/// ResolutionUnit
///
+ [ExifTagDescription((ushort)1, "None")]
+ [ExifTagDescription((ushort)2, "Inches")]
+ [ExifTagDescription((ushort)3, "Cm")]
ResolutionUnit = 0x0128,
///
diff --git a/src/ImageProcessorCore/Profiles/Exif/ExifTagDescriptionAttribute.cs b/src/ImageProcessorCore/Profiles/Exif/ExifTagDescriptionAttribute.cs
new file mode 100644
index 0000000000..b752dcf02c
--- /dev/null
+++ b/src/ImageProcessorCore/Profiles/Exif/ExifTagDescriptionAttribute.cs
@@ -0,0 +1,49 @@
+//
+// Copyright (c) James Jackson-South and contributors.
+// Licensed under the Apache License, Version 2.0.
+//
+
+namespace ImageProcessorCore
+{
+ using System;
+ using System.Linq;
+ using System.Reflection;
+
+ ///
+ /// Class that provides a description for an ExifTag value.
+ ///
+ [AttributeUsage(AttributeTargets.Field, AllowMultiple = true)]
+ internal sealed class ExifTagDescriptionAttribute : Attribute
+ {
+ private object value;
+ private string description;
+
+ ///
+ /// Initializes a new instance of the ExifTagDescriptionAttribute class.
+ ///
+ /// The value of the exif tag.
+ /// The description for the value of the exif tag.
+ public ExifTagDescriptionAttribute(object value, string description)
+ {
+ this.value = value;
+ this.description = description;
+ }
+
+ public static string GetDescription(ExifTag tag, object value)
+ {
+ FieldInfo field = tag.GetType().GetTypeInfo().GetDeclaredField(tag.ToString());
+ if (field == null)
+ return null;
+
+ foreach (CustomAttributeData customAttribute in field.CustomAttributes)
+ {
+ object attributeValue = customAttribute.ConstructorArguments[0].Value;
+
+ if (Equals(attributeValue, value))
+ return (string)customAttribute.ConstructorArguments[1].Value;
+ }
+
+ return null;
+ }
+ }
+}
diff --git a/src/ImageProcessorCore/Profiles/Exif/ExifValue.cs b/src/ImageProcessorCore/Profiles/Exif/ExifValue.cs
index 860ff30dc9..86b1d3b368 100644
--- a/src/ImageProcessorCore/Profiles/Exif/ExifValue.cs
+++ b/src/ImageProcessorCore/Profiles/Exif/ExifValue.cs
@@ -561,6 +561,10 @@ namespace ImageProcessorCore
private string ToString(object value)
{
+ string description = ExifTagDescriptionAttribute.GetDescription(Tag, value);
+ if (description != null)
+ return description;
+
switch (DataType)
{
case ExifDataType.Ascii:
diff --git a/tests/ImageProcessorCore.Tests/Profiles/Exif/ExifTagDescriptionAttributeTests.cs b/tests/ImageProcessorCore.Tests/Profiles/Exif/ExifTagDescriptionAttributeTests.cs
new file mode 100644
index 0000000000..1efb853774
--- /dev/null
+++ b/tests/ImageProcessorCore.Tests/Profiles/Exif/ExifTagDescriptionAttributeTests.cs
@@ -0,0 +1,38 @@
+//
+// Copyright (c) James Jackson-South and contributors.
+// Licensed under the Apache License, Version 2.0.
+//
+
+namespace ImageProcessorCore.Tests
+{
+ using Xunit;
+
+ public class ExifDescriptionAttributeTests
+ {
+ [Fact]
+ public void Test_ExifTag()
+ {
+ var exifProfile = new ExifProfile();
+
+ exifProfile.SetValue(ExifTag.ResolutionUnit, (ushort)1);
+ ExifValue value = exifProfile.GetValue(ExifTag.ResolutionUnit);
+ Assert.Equal("None", value.ToString());
+
+ exifProfile.SetValue(ExifTag.ResolutionUnit, (ushort)2);
+ value = exifProfile.GetValue(ExifTag.ResolutionUnit);
+ Assert.Equal("Inches", value.ToString());
+
+ exifProfile.SetValue(ExifTag.ResolutionUnit, (ushort)3);
+ value = exifProfile.GetValue(ExifTag.ResolutionUnit);
+ Assert.Equal("Cm", value.ToString());
+
+ exifProfile.SetValue(ExifTag.ResolutionUnit, (ushort)4);
+ value = exifProfile.GetValue(ExifTag.ResolutionUnit);
+ Assert.Equal("4", value.ToString());
+
+ exifProfile.SetValue(ExifTag.ImageWidth, 123);
+ value = exifProfile.GetValue(ExifTag.ImageWidth);
+ Assert.Equal("123", value.ToString());
+ }
+ }
+}