Browse Source

if Exif data exceeds 64K and is split over multiple App1 marker, it will be extended like the ICC profile does

pull/616/head
popow 8 years ago
parent
commit
f544e18e6a
  1. 10
      src/ImageSharp/Formats/Jpeg/PdfJsPort/PdfJsJpegDecoderCore.cs
  2. 16
      src/ImageSharp/MetaData/Profiles/Exif/ExifProfile.cs

10
src/ImageSharp/Formats/Jpeg/PdfJsPort/PdfJsJpegDecoderCore.cs

@ -472,7 +472,15 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.PdfJsPort
if (ProfileResolver.IsProfile(profile, ProfileResolver.ExifMarker)) if (ProfileResolver.IsProfile(profile, ProfileResolver.ExifMarker))
{ {
this.isExif = true; this.isExif = true;
this.MetaData.ExifProfile = new ExifProfile(profile); if (this.MetaData.ExifProfile == null)
{
this.MetaData.ExifProfile = new ExifProfile(profile);
}
else
{
// if the exif information exceeds 64K, it will be split over multiple APP1 marker
this.MetaData.ExifProfile.Extend(profile);
}
} }
} }

16
src/ImageSharp/MetaData/Profiles/Exif/ExifProfile.cs

@ -4,7 +4,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq;
using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Primitives; using SixLabors.ImageSharp.Primitives;
@ -18,7 +17,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Exif
/// <summary> /// <summary>
/// The byte array to read the EXIF profile from. /// The byte array to read the EXIF profile from.
/// </summary> /// </summary>
private readonly byte[] data; private byte[] data;
/// <summary> /// <summary>
/// The collection of EXIF values /// The collection of EXIF values
@ -230,6 +229,19 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Exif
this.values.Add(newExifValue); this.values.Add(newExifValue);
} }
/// <summary>
/// Extends the profile with additional data.
/// </summary>
/// <param name="bytes">The array containing addition profile data.</param>
public void Extend(byte[] bytes)
{
int currentLength = this.data.Length;
// the first 6 bytes are Exif00 and will be skipped
Array.Resize(ref this.data, currentLength + bytes.Length - 6);
Buffer.BlockCopy(bytes, 6, this.data, currentLength, bytes.Length - 6);
}
/// <summary> /// <summary>
/// Converts this instance to a byte array. /// Converts this instance to a byte array.
/// </summary> /// </summary>

Loading…
Cancel
Save