Browse Source

added EXIF chunk type and setting ExifProfile, if eXIf chunk data is present (#611)

af/merge-core
popow 8 years ago
parent
commit
e5bf5cf198
  1. 9
      src/ImageSharp/Formats/Png/PngChunkType.cs
  2. 6
      src/ImageSharp/Formats/Png/PngDecoderCore.cs

9
src/ImageSharp/Formats/Png/PngChunkType.cs

@ -4,7 +4,7 @@
namespace SixLabors.ImageSharp.Formats.Png
{
/// <summary>
/// Contains a list of of chunk types.
/// Contains a list of chunk types.
/// </summary>
internal enum PngChunkType : uint
{
@ -55,6 +55,11 @@ namespace SixLabors.ImageSharp.Formats.Png
/// <summary>
/// The pHYs chunk specifies the intended pixel size or aspect ratio for display of the image.
/// </summary>
Physical = 0x70485973U // pHYs
Physical = 0x70485973U, // pHYs
/// <summary>
/// The data chunk which contains the Exif profile.
/// </summary>
Exif = 0x65584966U // eXIf
}
}

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

@ -15,6 +15,7 @@ using SixLabors.ImageSharp.Formats.Png.Filters;
using SixLabors.ImageSharp.Formats.Png.Zlib;
using SixLabors.ImageSharp.Memory;
using SixLabors.ImageSharp.MetaData;
using SixLabors.ImageSharp.MetaData.Profiles.Exif;
using SixLabors.ImageSharp.PixelFormats;
namespace SixLabors.ImageSharp.Formats.Png
@ -250,6 +251,11 @@ namespace SixLabors.ImageSharp.Formats.Png
case PngChunkType.Text:
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);
break;
case PngChunkType.End:
this.isEndChunkReached = true;
break;

Loading…
Cancel
Save