diff --git a/src/ImageSharp/Formats/Jpeg/Components/Decoder/ProfileResolver.cs b/src/ImageSharp/Formats/Jpeg/Components/Decoder/ProfileResolver.cs
index 8273f20ea..a6d5faaea 100644
--- a/src/ImageSharp/Formats/Jpeg/Components/Decoder/ProfileResolver.cs
+++ b/src/ImageSharp/Formats/Jpeg/Components/Decoder/ProfileResolver.cs
@@ -32,7 +32,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.Components.Decoder
public static readonly byte[] AdobeMarker = Encoding.UTF8.GetBytes("Adobe");
///
- /// Returns a value indicating whether the passed bytes are a match to the profile identifer
+ /// Returns a value indicating whether the passed bytes are a match to the profile identifier
///
/// The bytes to check
/// The profile identifier
diff --git a/src/ImageSharp/MetaData/Profiles/Exif/ExifConstants.cs b/src/ImageSharp/MetaData/Profiles/Exif/ExifConstants.cs
index a76737b69..c96cc41b6 100644
--- a/src/ImageSharp/MetaData/Profiles/Exif/ExifConstants.cs
+++ b/src/ImageSharp/MetaData/Profiles/Exif/ExifConstants.cs
@@ -5,15 +5,6 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Exif
{
internal static class ExifConstants
{
- public static readonly byte[] ExifIdCode = {
- (byte)'E',
- (byte)'x',
- (byte)'i',
- (byte)'f',
- 0x00,
- 0x00
- };
-
public static readonly byte[] LittleEndianByteOrderMarker = {
(byte)'I',
(byte)'I',
diff --git a/src/ImageSharp/MetaData/Profiles/Exif/ExifProfile.cs b/src/ImageSharp/MetaData/Profiles/Exif/ExifProfile.cs
index 505ea582f..40c489d3a 100644
--- a/src/ImageSharp/MetaData/Profiles/Exif/ExifProfile.cs
+++ b/src/ImageSharp/MetaData/Profiles/Exif/ExifProfile.cs
@@ -5,6 +5,7 @@ using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
+using SixLabors.ImageSharp.Formats.Jpeg.Components.Decoder;
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Primitives;
@@ -15,11 +16,6 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Exif
///
public sealed class ExifProfile
{
- ///
- /// The EXIF ID code: ASCII "Exif" followed by two zeros.
- ///
- private static readonly byte[] ExifCode = { 69, 120, 105, 102, 0, 0 };
-
///
/// The byte array to read the EXIF profile from.
///
@@ -239,7 +235,8 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Exif
/// Converts this instance to a byte array.
///
/// Indicates, if the Exif ID code should be included.
- /// This Exif ID code should not be included in case of PNG's. Defaults to true.
+ /// The Exif Id Code is part of the JPEG APP1 segment. This Exif ID code should not be included in case of PNG's.
+ /// Defaults to true.
/// The
public byte[] ToByteArray(bool includeExifIdCode = true)
{
@@ -275,10 +272,10 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Exif
return false;
}
- int exifLength = ExifCode.Length;
- for (int i = 0; i < ExifCode.Length; i++)
+ int exifLength = ProfileResolver.ExifMarker.Length;
+ for (int i = 0; i < ProfileResolver.ExifMarker.Length; i++)
{
- if (exifBytes[i] != ExifCode[i])
+ if (exifBytes[i] != ProfileResolver.ExifMarker[i])
{
return false;
}
diff --git a/src/ImageSharp/MetaData/Profiles/Exif/ExifWriter.cs b/src/ImageSharp/MetaData/Profiles/Exif/ExifWriter.cs
index 14d180c05..ff0c6bf5c 100644
--- a/src/ImageSharp/MetaData/Profiles/Exif/ExifWriter.cs
+++ b/src/ImageSharp/MetaData/Profiles/Exif/ExifWriter.cs
@@ -5,6 +5,7 @@ using System;
using System.Buffers.Binary;
using System.Collections.Generic;
using System.Text;
+using SixLabors.ImageSharp.Formats.Jpeg.Components.Decoder;
using SixLabors.ImageSharp.Primitives;
namespace SixLabors.ImageSharp.MetaData.Profiles.Exif
@@ -42,13 +43,14 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Exif
/// Returns the EXIF data.
///
/// Indicates, if the Exif ID code should be included.
- /// This Exif ID code should not be included in case of PNG's. Defaults to true.
+ /// The Exif Id Code is part of the JPEG APP1 segment. This Exif ID code should not be included in case of PNG's.
+ /// Defaults to true.
///
/// The .
///
public byte[] GetData(bool includeExifIdCode = true)
{
- uint startIndex = 6;
+ uint startIndex = (uint)ProfileResolver.ExifMarker.Length;
uint length;
int exifIndex = -1;
int gpsIndex = -1;
@@ -86,19 +88,19 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Exif
if (includeExifIdCode)
{
- // Exif Code (6 bytes) + byte order marker (4 bytes)
- length += 10;
+ // Exif Id Code "Exif00" (6 bytes)
+ length += (uint)ProfileResolver.ExifMarker.Length;
}
else
{
// special case for PNG eXIf Chunk:
- // two bytes for the byte Order marker 'II', followed by the number 42 (0x2A) and a 0, making 4 bytes total
- length += 4;
-
// if the Exif Code ("Exif00") is not included, the start index is 0 instead of 6
startIndex = 0;
}
+ // two bytes for the byte Order marker 'II', followed by the number 42 (0x2A) and a 0, making 4 bytes total
+ length += (uint)ExifConstants.LittleEndianByteOrderMarker.Length;
+
length += 4 + 2;
byte[] result = new byte[length];
@@ -106,8 +108,8 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Exif
int i = 0;
if (includeExifIdCode)
{
- ExifConstants.ExifIdCode.AsSpan().CopyTo(result); // 0-5
- i += ExifConstants.ExifIdCode.Length;
+ ProfileResolver.ExifMarker.AsSpan().CopyTo(result); // 0-5
+ i += ProfileResolver.ExifMarker.Length;
}
// the byte order marker for little-endian, followed by the number 42 and a 0