Skip to content

Conversation

JoseEliasSantos
Copy link
Contributor

Prerequisites

  • I have written a descriptive pull-request title
  • I have verified that there are no overlapping pull-requests open
  • I have verified that I am following the existing coding patterns and practice as demonstrated in the repository. These follow strict Stylecop rules 👮.
  • I have provided test coverage for my change (where applicable)

Description

Fixed discussion and issue bug
https://github.com/SixLabors/ImageSharp/discussions/2564
https://github.com/SixLabors/ImageSharp/issues/2565

@CLAassistant
Copy link

CLAassistant commented Oct 19, 2023

CLA assistant check
All committers have signed the CLA.

if (ProfileResolver.IsProfile(bytes, ProfileResolver.JFifMarker)
|| ProfileResolver.IsProfile(bytes, ProfileResolver.JFxxMarker))
|| ProfileResolver.IsProfile(bytes, ProfileResolver.JFxxMarker)
|| ProfileResolver.IsProfile(bytes, ProfileResolver.OSQidMaker))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While this works, I'm not sure it's the correct fix.

I think we might be able to simply remove the throw when the marker doesn't match a JFIF one and skip the remaining bytes.

What is OSQidMaker? Can you please supply more information?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In fact, in my research I didn't find markers that specified such a conversion starting with these bytes, but I have images of a camera that always has these bytes at the beginning. I also had success in all tests when ignoring this if but I don't know what more problems this could cause. I'm running a fork of the lib in my application and I don't get any more errors

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The JFIF JFXX headers contain metadata and we can actually operate without them. Your images actually contain a JFIF header in an APP0 block just after the camera junk.

I can’t accept the fix as-is because the values are non-standard so we should try a more robust solution as suggested

Comment on lines 30 to 33
public static ReadOnlySpan<byte> OSQidMaker => new[]
{
(byte)'\n', (byte)'[', (byte)'I', (byte)'D', (byte)' '
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
public static ReadOnlySpan<byte> OSQidMaker => new[]
{
(byte)'\n', (byte)'[', (byte)'I', (byte)'D', (byte)' '
};
public static ReadOnlySpan<byte> OSQidMaker => new[] { (byte)'\n', (byte)'[', (byte)'I', (byte)'D', (byte)' ' };

I'd like to have it written as one-liner, because when we are able to use ut8-literals it's easier to find & replace these.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a good suggestion, but the other properties of the class already follow this same pattern, so I chose to keep it.

@JimBobSquarePants
Copy link
Member

JimBobSquarePants commented Nov 6, 2023

Hi @JoseEliasSantos I can see you updated your PR from main. As commented, we won't be able to proceed #2566 (comment) with the fix you have applied. If you are not able to make the suggested changes, that's OK. I can close this and create a new PR.

Copy link
Member

@JimBobSquarePants JimBobSquarePants left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've made the required changes here to make JFIF marker optional. Thanks for your assistance here 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants