Skip to content

Clarify the createImageBitmap orientation metadata handling #11234

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

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Prev Previous commit
Separate the steps
  • Loading branch information
Hajime-san committed Apr 24, 2025
commit 81d43bf81f5440f6d43b03acf4c0f709d0c9b264
26 changes: 16 additions & 10 deletions source
Original file line number Diff line number Diff line change
Expand Up @@ -119255,16 +119255,22 @@ dictionary <dfn dictionary>ImageBitmapOptions</dfn> {
choice of scaling algorithm.</p></li>

<li>
<p>Apply the orientation to <var>output</var>, if <var>image</var> is an <code>img</code>
element or a <code>Blob</code> object that contains orientation metadata of the source
such as <ref>EXIF</ref> metadata at first, and if the value of the <dfn dict-member
for="ImageBitmapOptions"><code data-x="dom-ImageBitmapOptions-imageOrientation">imageOrientation
</code></dfn> member of <var>options</var> is "<dfn enum-value for="ImageOrientation"><code
data-x="dom-ImageOrientation-flipY">flipY</code></dfn>", <var>output</var> must be flipped
vertically.</p>

<p class="note">If the value is "<dfn enum-value for="ImageOrientation"><code
data-x="dom-ImageOrientation-from-image">from-image</code></dfn>", no extra step is needed.</p>
<p>If <var>image</var> is an <code>img</code> element or a <code>Blob</code> object that
contains orientation metadata of the source such as <ref>EXIF</ref> metadata, apply the
orientation to <var>output</var>.</p>
<p>Let <var>val</var> be the value of <dfn dict-member for="ImageBitmapOptions"><code
data-x="dom-ImageBitmapOptions-imageOrientation">imageOrientation</code></dfn> member of
<var>options</var>, and then run these substeps:</p>

Copy link
Member

Choose a reason for hiding this comment

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

You want these to be separate steps.

I also worry a bit that this isn't the right place to do it, but perhaps that can later be more properly abstracted. As we should really decode images in a single place after they come from the network and there we should apply the orientation metadata.

Copy link
Author

Choose a reason for hiding this comment

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

I also worry a bit that this isn't the right place to do it, but perhaps that can later be more properly abstracted. As we should really decode images in a single place after they come from the network and there we should apply the orientation metadata.

There has been no agreement and this is merely a suggestion and implementation-oriented, but there was a conversation about making createImageBitmap a no-op to make it more tolerant of performance and reference from external specifications such as WebGPU.
As a result, I think it is best to just write down how EXIF ​​is handled for now, so as not to restrict implementation-oriented behavior such as the timing of decoding or storing byte sequences including EXIF ​​as internal variables in the API implementation.

cc: @ccameron-chromium

<ol>
<li><p>If <var>val</var> is "<dfn enum-value for="ImageOrientation"><code
Copy link
Member

Choose a reason for hiding this comment

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

This is applicable regardless of whether the imageOrientation member is given.

Copy link
Author

Choose a reason for hiding this comment

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

Got it, I changed to reflect the orientation at first.

data-x="dom-ImageOrientation-from-image">from-image</code></dfn>", no extra step is needed.</p>
</li>
<li><p>If <var>val</var> is "<dfn enum-value for="ImageOrientation"><code
data-x="dom-ImageOrientation-flipY">flipY</code></dfn>", the <var>output</var> must be
flipped vertically.</p>
</li>
</ol>

<p class="note">There used to be a "<dfn><code
data-x="dom-ImageBitmapOptions-imageOrientation-none">none</code></dfn>" enum value. It was
Expand Down