diff --git a/src/ImageProcessor.Web/NET45/ImageFactoryExtensions.cs b/src/ImageProcessor.Web/NET45/ImageFactoryExtensions.cs index 1243bd327..0c8788cd9 100644 --- a/src/ImageProcessor.Web/NET45/ImageFactoryExtensions.cs +++ b/src/ImageProcessor.Web/NET45/ImageFactoryExtensions.cs @@ -15,6 +15,7 @@ namespace ImageProcessor.Web using System; using System.Collections.Generic; using System.Drawing; + using System.Drawing.Imaging; using System.IO; using System.Linq; using ImageProcessor.Extensions; @@ -105,6 +106,25 @@ namespace ImageProcessor.Web { factory.Update(processor.Invoke(factory)); } + + // Set the property item information from any Exif metadata. + // We do this here so that they can be changed between processor methods. + if (factory.PreserveExifData) + { + foreach (KeyValuePair propertItem in factory.ExifPropertyItems) + { + try + { + factory.Image.SetPropertyItem(propertItem.Value); + } + // ReSharper disable once EmptyGeneralCatchClause + catch + { + // Do nothing. The image format does not handle EXIF data. + // TODO: empty catch is fierce code smell. + } + } + } } } } diff --git a/src/ImageProcessor/ImageFactory.cs b/src/ImageProcessor/ImageFactory.cs index 4262c1449..92f89b0f8 100644 --- a/src/ImageProcessor/ImageFactory.cs +++ b/src/ImageProcessor/ImageFactory.cs @@ -37,11 +37,6 @@ namespace ImageProcessor /// private const int DefaultJpegQuality = 90; - /// - /// Whether to preserve exif metadata - /// - private readonly bool preserveExifData; - /// /// The backup image format. /// @@ -76,11 +71,11 @@ namespace ImageProcessor /// Initializes a new instance of the class. /// /// - /// Whether to preserve exif metadata. Defaults to false. + /// Whether to preserve exif metadata. Defaults to true. /// public ImageFactory(bool preserveExifData = true) { - this.preserveExifData = preserveExifData; + this.PreserveExifData = preserveExifData; this.ExifPropertyItems = new ConcurrentDictionary(); } #endregion @@ -142,6 +137,11 @@ namespace ImageProcessor } } + /// + /// Gets or sets a value indicating whether to preserve exif metadata. + /// + public bool PreserveExifData { get; set; } + /// /// Gets or sets the exif property items. /// @@ -182,7 +182,7 @@ namespace ImageProcessor this.backupImageFormat = this.ImageFormat; this.isIndexed = ImageUtils.IsIndexed(this.Image); - if (this.preserveExifData) + if (this.PreserveExifData) { foreach (PropertyItem propertyItem in this.Image.PropertyItems) { @@ -244,7 +244,7 @@ namespace ImageProcessor this.ImageFormat = imageFormat; this.isIndexed = ImageUtils.IsIndexed(this.Image); - if (this.preserveExifData) + if (this.PreserveExifData) { foreach (PropertyItem propertyItem in this.Image.PropertyItems) { @@ -1077,7 +1077,7 @@ namespace ImageProcessor // Set the property item information from any Exif metadata. // We do this here so that they can be changed between processor methods. - if (this.preserveExifData) + if (this.PreserveExifData) { foreach (KeyValuePair propertItem in this.ExifPropertyItems) { diff --git a/src/Images/Thumbs.db.REMOVED.git-id b/src/Images/Thumbs.db.REMOVED.git-id new file mode 100644 index 000000000..9f1353d69 --- /dev/null +++ b/src/Images/Thumbs.db.REMOVED.git-id @@ -0,0 +1 @@ +a3324e1e607ce97a44495fe239782e3b76da6129 \ No newline at end of file diff --git a/src/Images/WP_000009.jpg.REMOVED.git-id b/src/Images/WP_000009.jpg.REMOVED.git-id new file mode 100644 index 000000000..19785c8e5 --- /dev/null +++ b/src/Images/WP_000009.jpg.REMOVED.git-id @@ -0,0 +1 @@ +85a8ae18f9955def2b42ba9240bce4de1bfe5781 \ No newline at end of file