From ce396ccef851fdc2023068706ce97d5536aed42a Mon Sep 17 00:00:00 2001 From: Dirk Lemstra Date: Sun, 14 May 2017 10:34:50 +0200 Subject: [PATCH] Remove resolution value from profile before setting it if it does not have the correct data type. (Fixes #215) --- .../MetaData/Profiles/Exif/ExifProfile.cs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/ImageSharp/MetaData/Profiles/Exif/ExifProfile.cs b/src/ImageSharp/MetaData/Profiles/Exif/ExifProfile.cs index b270caf5d..1217fc0a9 100644 --- a/src/ImageSharp/MetaData/Profiles/Exif/ExifProfile.cs +++ b/src/ImageSharp/MetaData/Profiles/Exif/ExifProfile.cs @@ -238,11 +238,18 @@ namespace ImageSharp private void SyncResolution(ExifTag tag, double resolution) { ExifValue value = this.GetValue(tag); - if (value != null) + if (value == null) { - Rational newResolution = new Rational(resolution, false); - this.SetValue(tag, newResolution); + return; } + + if (value.IsArray || value.DataType != ExifDataType.Rational) + { + this.RemoveValue(value.Tag); + } + + Rational newResolution = new Rational(resolution, false); + this.SetValue(tag, newResolution); } private void InitializeValues()