w3c / w3c/webcodecs

Allow disabling automatic reorientation in `ImageDecoder`

Open
#870 3 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
HTML
Stars
1.3k
Forks
194
Avg merge
1d 13h
Merged PRs (30d)
3

Description

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;
}

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

The issue identifies ImageDecoder and the ImageDecodeOptions WebIDL definition as the entry point; start by reviewing that proposal and the linked PDF and DCT references. Done means reaching a settled specification for disabling orientation metadata handling without requiring a second reorientation.

Written by the indexing model from the issue text.

Assessment

Tech stack
html
Domain
api
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.