From b62e56d95265dfba1a848c8903093f402883dcab Mon Sep 17 00:00:00 2001 From: Cameron McCormack Date: Wed, 3 Jun 2020 10:37:57 +1000 Subject: [PATCH] Expose image orientation metadata on HTMLImageElement Fixes #5602. --- source | 81 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 80 insertions(+), 1 deletion(-) diff --git a/source b/source index 92a08babf1b..d0be48f9f92 100644 --- a/source +++ b/source @@ -25882,6 +25882,8 @@ interface HTMLImageElement : HTMLElement { [CEReactions] attribute unsigned long height; readonly attribute unsigned long naturalWidth; readonly attribute unsigned long naturalHeight; + readonly attribute unsigned long intrinsicOrientationAngle; + readonly attribute boolean intrinsicOrientationFlip; readonly attribute boolean complete; readonly attribute USVString currentSrc; [CEReactions] attribute DOMString referrerPolicy; @@ -26216,6 +26218,14 @@ interface HTMLImageElement : HTMLElement { or zero if the dimensions are not known.

+
image . intrinsicOrientationAngle
+
image . intrinsicOrientationFlip
+ +
+

These attributes return the orientation metadata of the image, or zero and false if there is + none.

+
+
image . complete
@@ -26278,6 +26288,16 @@ interface HTMLImageElement : HTMLElement { any rotation needed to correctly orient the image, regardless of the value of the 'image-orientation' property.

+

The IDL attribute intrinsicOrientationAngle must + return the angle of the image data's intrinsic + orientation.

+ +

The IDL attribute intrinsicOrientationFlip must + return true if the image data's intrinsic + orientation applies the optional horizontal flip, and false otherwise.

+

The IDL attribute complete must return true if any of the following conditions is true:

@@ -27265,7 +27285,8 @@ was an English <a href="/wiki/Music_hall">music hall</a> singer, ...pending request is initially set to null.

An image request has a state, current URL, and image data.

+ data-x="img-req-url">current URL, image data, and + orientation.

An image request's state is one of the following:

@@ -27296,6 +27317,64 @@ was an English <a href="/wiki/Music_hall">music hall</a> singer, ...An image request's image data is the decoded image data.

+

An image request's image data has an associated + intrinsic orientation, which is the orthogonal transformation that was applied to the + raw data in the image during its decoding. The transformation consists of a rotation of 0, 90, + 180, or 270 degrees, followed by an optional horizontal flip. If no transformation was applied, + the intrinsic orientation is considered to be 0 degrees with no horizontal flip.

+ +
+ +

This transformation is the one that is automatically applied when the + 'image-orientation' property is set to 'from-image'.

+ +

For JPEG images, the intrinsic orientation is the orientation specified by the + EXIF metadata Orientation tag. Orientation tag values correspond to intrinsic + orientation values as follows:

+ + + + + + + + + + + + + +
Tag value + Angle + Horizontal flip +
1 + 0° + no +
2 + 0° + yes +
3 + 180° + no +
4 + 180° + yes +
5 + 90° + yes +
6 + 90° + no +
7 + 270° + yes +
8 + 270° + no +
+ +
+

When an image request's state is either partially available or completely available, the image request is said to be available.