diff --git a/src/ImageSharp/Formats/Jpeg/GolangPort/OrigJpegConstants.cs b/src/ImageSharp/Formats/Jpeg/GolangPort/OrigJpegConstants.cs index 57bc1118c..51c14c285 100644 --- a/src/ImageSharp/Formats/Jpeg/GolangPort/OrigJpegConstants.cs +++ b/src/ImageSharp/Formats/Jpeg/GolangPort/OrigJpegConstants.cs @@ -36,22 +36,36 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.GolangPort /// /// Describes the EXIF specific markers /// - public static readonly byte[] JFifMarker = { JFif.J, JFif.F, JFif.I, JFif.F, JFif.Null }; + public static readonly byte[] JFifMarker = ToAsciiBytes("JFIF\0"); /// /// Describes the EXIF specific markers /// - public static readonly byte[] IccMarker = { ICC.I, ICC.C, ICC.C, ICC.UnderScore, ICC.P, ICC.R, ICC.O, ICC.F, ICC.I, ICC.L, ICC.E, ICC.Null }; + public static readonly byte[] IccMarker = ToAsciiBytes("ICC_PROFILE\0"); /// /// Describes the ICC specific markers /// - public static readonly byte[] ExifMarker = { Exif.E, Exif.X, Exif.I, Exif.F, Exif.Null, Exif.Null }; + public static readonly byte[] ExifMarker = ToAsciiBytes("Exif\0\0"); /// /// Describes Adobe specific markers /// - public static readonly byte[] AdobeMarker = { Adobe.A, Adobe.D, Adobe.O, Adobe.B, Adobe.E }; + public static readonly byte[] AdobeMarker = ToAsciiBytes("Adobe"); + + // No Linq Select on NetStandard 1.1 + private static byte[] ToAsciiBytes(string str) + { + int length = str.Length; + byte[] bytes = new byte[length]; + char[] chars = str.ToCharArray(); + for (int i = 0; i < length; i++) + { + bytes[i] = (byte)chars[i]; + } + + return bytes; + } } /// @@ -225,31 +239,6 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.GolangPort /// internal static class Adobe { - /// - /// Represents A in ASCII - /// - public const byte A = 0x41; - - /// - /// Represents d in ASCII - /// - public const byte D = 0x64; - - /// - /// Represents b in ASCII - /// - public const byte O = 0x6F; - - /// - /// Represents b in ASCII - /// - public const byte B = 0x62; - - /// - /// Represents e in ASCII - /// - public const byte E = 0x65; - /// /// The color transform is unknown.(RGB or CMYK) /// @@ -265,92 +254,5 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.GolangPort /// public const int ColorTransformYcck = 2; } - - /// - /// Contains EXIF specific markers - /// - internal static class Exif - { - /// - /// Represents E in ASCII - /// - public const byte E = 0x45; - - /// - /// Represents x in ASCII - /// - public const byte X = 0x78; - - /// - /// Represents i in ASCII - /// - public const byte I = 0x69; - - /// - /// Represents f in ASCII - /// - public const byte F = 0x66; - - /// - /// Represents the null "0" marker - /// - public const byte Null = 0x0; - } - - /// - /// Contains ICC specific markers - /// - internal static class ICC - { - /// - /// Represents I in ASCII - /// - public const byte I = 0x49; - - /// - /// Represents C in ASCII - /// - public const byte C = 0x43; - - /// - /// Represents _ in ASCII - /// - public const byte UnderScore = 0x5F; - - /// - /// Represents P in ASCII - /// - public const byte P = 0x50; - - /// - /// Represents R in ASCII - /// - public const byte R = 0x52; - - /// - /// Represents O in ASCII - /// - public const byte O = 0x4F; - - /// - /// Represents F in ASCII - /// - public const byte F = 0x46; - - /// - /// Represents L in ASCII - /// - public const byte L = 0x4C; - - /// - /// Represents E in ASCII - /// - public const byte E = 0x45; - - /// - /// Represents the null "0" marker - /// - public const byte Null = 0x0; - } } } \ No newline at end of file diff --git a/src/ImageSharp/Formats/Jpeg/GolangPort/OrigJpegDecoderCore.cs b/src/ImageSharp/Formats/Jpeg/GolangPort/OrigJpegDecoderCore.cs index 96ade60a0..538e56d91 100644 --- a/src/ImageSharp/Formats/Jpeg/GolangPort/OrigJpegDecoderCore.cs +++ b/src/ImageSharp/Formats/Jpeg/GolangPort/OrigJpegDecoderCore.cs @@ -403,7 +403,8 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.GolangPort /// The private static bool IsProfile(Span bytesToCheck, Span profileIdentifier) { - return bytesToCheck.Slice(0, profileIdentifier.Length).SequenceEqual(profileIdentifier); + return bytesToCheck.Length >= profileIdentifier.Length + && bytesToCheck.Slice(0, profileIdentifier.Length).SequenceEqual(profileIdentifier); } ///