Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow zero DPI and only throw at EOF when not enough data #2324

Merged
merged 3 commits into from
Jan 24, 2023

Conversation

JimBobSquarePants
Copy link
Member

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

Fixes #2315

The image has two issues.

  1. Zero density unit values in the JFIF header.
  2. Erroneous marker data at the end of the stream following the image data.

I've relaxed the decoder to cater for these cases.

cc\ @br3aker

return;
}

if (this.Metadata != null && this.Frame != null && spectralConverter.HasPixelBuffer())
Copy link
Contributor

@br3aker br3aker Jan 24, 2023

Choose a reason for hiding this comment

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

As we want to know if image was decoded at this point - we could use Converted of SpectralConverter as it's called right after baseline image is decoded.

Two problems:

  1. It's protected, not really a problem creating a public getter though
  2. It's not set for progressive images as those are lazy-converted during pixel buffer -> Image<T> step which won't be called until parsing loop is finished, not the wisest solution from me

I'd probably refactor spectral converter so it could better describe its state.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah. This felt a little hacky. State matching would be better.

Copy link
Contributor

@br3aker br3aker left a comment

Choose a reason for hiding this comment

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

Looks good!

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.

Exception Input stream does not have enough bytes in version 2.1.1+
2 participants