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

Prefer the Width/Height of the image data, rather than the image dictionary, for JPEG 2000 images (issue 9650) #9897

Merged
merged 2 commits into from
Aug 1, 2018

Commits on Aug 1, 2018

  1. Add more validation of the /Filter entry, in image dictionaries, to t…

    …he `PDFImage` constructor
    
    Given that the code is currently assuming that the /Filter entry is a `Name`, it cannot hurt to actually ensure that's the case.
    
    Also fixes an error message, for JPEG 2000 images with unsupported ColorSpaces, since `this.numComps` hasn't been initialized when it's accessed during the `throw new Error()` invocation.
    Snuffleupagus committed Aug 1, 2018
    Configuration menu
    Copy the full SHA
    17f6590 View commit details
    Browse the repository at this point in the history
  2. Prefer the Width/Height of the image data, rather than the image dict…

    …ionary, for JPEG 2000 images (issue 9650)
    
    According to the PDF specification, see https://www.adobe.com/content/dam/acom/en/devnet/acrobat/pdfs/PDF32000_2008.pdf#page=45
    > When using the JPXDecode filter with image XObjects, the following changes to and constraints on some entries in the image dictionary shall apply (see 8.9.5, "Image Dictionaries" for details on these entries):
    >
    >  - Width and Height shall match the corresponding width and height values in the JPEG2000 data.
    >
    >  - . . .
    
    Hence it seems reasonable to use the Width/Height of the image data *itself*, rather than the image dictionary when there's a mismatch. Given that JPEG 2000 images are already being parsed, in order to obtain basic parameters, the actual Width/Height is readily available in the `PDFImage` constructor.
    Snuffleupagus committed Aug 1, 2018
    Configuration menu
    Copy the full SHA
    3ce4201 View commit details
    Browse the repository at this point in the history