Skip to content

Commit 48cecd3

Browse files
Make JFIF marker optional
1 parent ca1fd46 commit 48cecd3

File tree

4 files changed

+3
-15
lines changed

4 files changed

+3
-15
lines changed

src/ImageSharp/Formats/Jpeg/Components/Decoder/JFifMarker.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,7 @@ public static bool TryParse(ReadOnlySpan<byte> bytes, out JFifMarker marker)
7373
{
7474
// Some images incorrectly use JFXX as the App0 marker (Issue 2478)
7575
if (ProfileResolver.IsProfile(bytes, ProfileResolver.JFifMarker)
76-
|| ProfileResolver.IsProfile(bytes, ProfileResolver.JFxxMarker)
77-
|| ProfileResolver.IsProfile(bytes, ProfileResolver.OSQidMaker))
76+
|| ProfileResolver.IsProfile(bytes, ProfileResolver.JFxxMarker))
7877
{
7978
byte majorVersion = bytes[5];
8079
byte minorVersion = bytes[6];

src/ImageSharp/Formats/Jpeg/Components/Decoder/ProfileResolver.cs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,6 @@ internal static class ProfileResolver
2424
(byte)'J', (byte)'F', (byte)'X', (byte)'X', (byte)'\0'
2525
};
2626

27-
/// <summary>
28-
/// Gets the \n[ID or 10 91 73 68 32 specific markers.
29-
/// </summary>
30-
public static ReadOnlySpan<byte> OSQidMaker => new[]
31-
{
32-
(byte)'\n', (byte)'[', (byte)'I', (byte)'D', (byte)' '
33-
};
34-
3527
/// <summary>
3628
/// Gets the ICC specific markers.
3729
/// </summary>

src/ImageSharp/Formats/Jpeg/JpegDecoderCore.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -753,10 +753,7 @@ private void ProcessApplicationHeaderMarker(BufferedReadStream stream, int remai
753753
Span<byte> temp = stackalloc byte[2 * 16 * 4];
754754

755755
stream.Read(temp, 0, JFifMarker.Length);
756-
if (!JFifMarker.TryParse(temp, out this.jFif))
757-
{
758-
JpegThrowHelper.ThrowNotSupportedException("Unknown App0 Marker - Expected JFIF.");
759-
}
756+
_ = JFifMarker.TryParse(temp, out this.jFif);
760757

761758
remaining -= JFifMarker.Length;
762759

tests/ImageSharp.Tests/Formats/Jpg/JpegDecoderTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ public void Issue2478_DecodeWorks<TPixel>(TestImageProvider<TPixel> provider)
330330
[Theory]
331331
[WithFile(TestImages.Jpeg.Issues.Issue2564, PixelTypes.Rgba32)]
332332
public void Issue2564_DecodeWorks<TPixel>(TestImageProvider<TPixel> provider)
333-
where TPixel : unmanaged, IPixel<TPixel>
333+
where TPixel : unmanaged, IPixel<TPixel>
334334
{
335335
using Image<TPixel> image = provider.GetImage(JpegDecoder.Instance);
336336
image.DebugSave(provider);

0 commit comments

Comments
 (0)