Browse Source

if ignoreMetadata is set, EXIF chunk will be ignored

pull/616/head
popow 8 years ago
parent
commit
89f60fc96d
  1. 10
      src/ImageSharp/Formats/Png/PngDecoderCore.cs
  2. 2
      src/ImageSharp/Formats/Png/PngEncoderCore.cs

10
src/ImageSharp/Formats/Png/PngDecoderCore.cs

@ -252,9 +252,13 @@ namespace SixLabors.ImageSharp.Formats.Png
this.ReadTextChunk(metadata, chunk.Data.Array, chunk.Length);
break;
case PngChunkType.Exif:
byte[] exifData = new byte[chunk.Length];
Buffer.BlockCopy(chunk.Data.Array, 0, exifData, 0, chunk.Length);
metadata.ExifProfile = new ExifProfile(exifData);
if (!this.ignoreMetadata)
{
byte[] exifData = new byte[chunk.Length];
Buffer.BlockCopy(chunk.Data.Array, 0, exifData, 0, chunk.Length);
metadata.ExifProfile = new ExifProfile(exifData);
}
break;
case PngChunkType.End:
this.isEndChunkReached = true;

2
src/ImageSharp/Formats/Png/PngEncoderCore.cs

@ -533,7 +533,7 @@ namespace SixLabors.ImageSharp.Formats.Png
private void WriteExifChunk<TPixel>(Stream stream, Image<TPixel> image)
where TPixel : struct, IPixel<TPixel>
{
if (image.MetaData.ExifProfile.Values.Count > 0)
if (image.MetaData.ExifProfile?.Values.Count > 0)
{
this.WriteChunk(stream, PngChunkType.Exif, image.MetaData.ExifProfile.RawData);
}

Loading…
Cancel
Save