diff --git a/src/ImageSharp/Formats/Png/PngEncoderCore.cs b/src/ImageSharp/Formats/Png/PngEncoderCore.cs index f17c9009a6..8bd3d3eb6d 100644 --- a/src/ImageSharp/Formats/Png/PngEncoderCore.cs +++ b/src/ImageSharp/Formats/Png/PngEncoderCore.cs @@ -221,6 +221,7 @@ namespace SixLabors.ImageSharp.Formats.Png this.WritePhysicalChunk(stream, image); this.WriteGammaChunk(stream); + this.WriteExifChunk(stream, image); this.WriteDataChunks(image.Frames.RootFrame, stream); this.WriteEndChunk(stream); stream.Flush(); @@ -523,6 +524,21 @@ namespace SixLabors.ImageSharp.Formats.Png } } + /// + /// Writes the eXIf chunk to the stream, if any EXIF Profile values are present in the meta data. + /// + /// The pixel format. + /// The containing image data. + /// The image. + private void WriteExifChunk(Stream stream, Image image) + where TPixel : struct, IPixel + { + if (image.MetaData.ExifProfile.Values.Count > 0) + { + this.WriteChunk(stream, PngChunkType.Exif, image.MetaData.ExifProfile.RawData); + } + } + /// /// Writes the gamma information to the stream. /// diff --git a/src/ImageSharp/MetaData/Profiles/Exif/ExifProfile.cs b/src/ImageSharp/MetaData/Profiles/Exif/ExifProfile.cs index 0f19083e53..d3f97c46cb 100644 --- a/src/ImageSharp/MetaData/Profiles/Exif/ExifProfile.cs +++ b/src/ImageSharp/MetaData/Profiles/Exif/ExifProfile.cs @@ -3,7 +3,6 @@ using System; using System.Collections.Generic; -using System.Collections.ObjectModel; using System.IO; using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.Primitives; @@ -95,6 +94,11 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Exif /// public ExifParts Parts { get; set; } + /// + /// Gets the byte data array containing the exif data. + /// + public byte[] RawData => this.data; + /// /// Gets the tags that where found but contained an invalid value. ///