Browse Source

writes the eXIf chunk to the stream during encoding (#611)

af/merge-core
popow 8 years ago
parent
commit
a5864ac9e7
  1. 16
      src/ImageSharp/Formats/Png/PngEncoderCore.cs
  2. 6
      src/ImageSharp/MetaData/Profiles/Exif/ExifProfile.cs

16
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
}
}
/// <summary>
/// Writes the eXIf chunk to the stream, if any EXIF Profile values are present in the meta data.
/// </summary>
/// <typeparam name="TPixel">The pixel format.</typeparam>
/// <param name="stream">The <see cref="Stream"/> containing image data.</param>
/// <param name="image">The image.</param>
private void WriteExifChunk<TPixel>(Stream stream, Image<TPixel> image)
where TPixel : struct, IPixel<TPixel>
{
if (image.MetaData.ExifProfile.Values.Count > 0)
{
this.WriteChunk(stream, PngChunkType.Exif, image.MetaData.ExifProfile.RawData);
}
}
/// <summary>
/// Writes the gamma information to the stream.
/// </summary>

6
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
/// </summary>
public ExifParts Parts { get; set; }
/// <summary>
/// Gets the byte data array containing the exif data.
/// </summary>
public byte[] RawData => this.data;
/// <summary>
/// Gets the tags that where found but contained an invalid value.
/// </summary>

Loading…
Cancel
Save