Skip to content

Allow disabling automatic reorientation in ImageDecoder #870

@padenot

Description

@padenot

In PDFs, there are frequently images that do have orientation information in the metadata, but they must not be taken into account during rendering.

https://github.com/mozilla/pdf.js is used all over the web and in some browsers, and takes advantage of ImageDecoder when available, leading to ridiculous performance improvement. They would like to not reorient images, or more accurately, not have to have them reoriented twice (once by the browser engine, and once themselves).

Quoting the PDF spec (https://opensource.adobe.com/dc-acrobat-sdk-docs/pdfstandards/PDF32000_2008.pdf#page=43, bottom of the table):

Parameters that control the decoding process as well as other metadata is embedded within the encoded data
stream using a notation referred to as “markers”. When it defined the use of JPEG images within PostScript data
streams, Adobe System Incorporated defined a particular set of rules pertaining to which markers are to be
recognized, which are to be ignored and which are considered errors. A specific Adobe-defined marker was also
introduced. The exact rules for producing and consuming DCT encoded data within PostScript are provide in
Adobe Technical Note #5116 (reference). PDF DCT Encoding shall exactly follow those rules established by
Adobe for PostScript.

The reference is https://pdfa.org/norm-refs/5116.DCT_Filter.pdf. There is no mention of orientation, and so it has to be ignored for compliance.

I simply propose the following addition to the spec:

partial dict  ImageDecodeOptions {
    boolean ignoreOrientationMetadata = false;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions