Bug 231063

Summary: ImageBitmap should honor EXIF orientation
Product: WebKit Reporter: Cameron McCormack (:heycam) <heycam>
Component: CanvasAssignee: Cameron McCormack (:heycam) <heycam>
Status: RESOLVED FIXED    
Severity: Normal CC: cdumez, changseok, clopez, dino, esprehn+autocc, ews-watchlist, gyuyoung.kim, kondapallykalyan, micah.millereshleman, mmaxfield, sabouhallawa, webkit-bug-importer, youennf
Priority: P2 Keywords: InRadar
Version: WebKit Local Build   
Hardware: Unspecified   
OS: Unspecified   
See Also: https://github.com/web-platform-tests/wpt/pull/31287
https://bugs.webkit.org/show_bug.cgi?id=242169
Attachments:
Description Flags
Patch
none
Patch
none
Patch
mmaxfield: review+
Patch for landing none

Cameron McCormack (:heycam)
Reported 2021-09-30 22:28:34 PDT
.
Attachments
Patch (11.51 KB, patch)
2021-10-17 20:23 PDT, Cameron McCormack (:heycam)
no flags
Patch (12.50 KB, patch)
2021-10-17 21:34 PDT, Cameron McCormack (:heycam)
no flags
Patch (12.65 KB, patch)
2021-10-17 23:38 PDT, Cameron McCormack (:heycam)
mmaxfield: review+
Patch for landing (20.28 KB, patch)
2021-10-18 19:48 PDT, Cameron McCormack (:heycam)
no flags
Radar WebKit Bug Importer
Comment 1 2021-09-30 23:20:02 PDT
Cameron McCormack (:heycam)
Comment 2 2021-10-12 22:12:51 PDT
Filed https://github.com/whatwg/html/issues/7210 to get clarity in the HTML spec about exactly how EXIF orientation and the image-orientation property should influence createImageBitmap.
Cameron McCormack (:heycam)
Comment 3 2021-10-17 20:23:59 PDT
Cameron McCormack (:heycam)
Comment 4 2021-10-17 20:24:51 PDT
Submitted web-platform-tests pull request: https://github.com/web-platform-tests/wpt/pull/31287
EWS Watchlist
Comment 5 2021-10-17 20:25:05 PDT
This patch modifies the imported WPT tests. Please ensure that any changes on the tests (not coming from a WPT import) are exported to WPT. Please see https://trac.webkit.org/wiki/WPTExportProcess
Cameron McCormack (:heycam)
Comment 6 2021-10-17 21:34:30 PDT
Cameron McCormack (:heycam)
Comment 7 2021-10-17 23:38:54 PDT
Myles C. Maxfield
Comment 8 2021-10-18 14:02:47 PDT
Comment on attachment 441561 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=441561&action=review > Source/WebCore/html/ImageBitmap.cpp:391 > + auto orientation = imageForRender->orientation(); > + if (orientation == ImageOrientation::FromImage) > + orientation = ImageOrientation::None; I've had to write similar code to this elsewhere. I think we should try to push this complexity somewhere lower level. I'm not sure where, though. > Source/WebCore/platform/graphics/ImageOrientation.h:111 > + ImageOrientation flipY() const Can this be named something like "ImageOrientationWithFlippedY()"? It sounds like it would be a non-const function.
Said Abou-Hallawa
Comment 9 2021-10-18 14:18:24 PDT
Comment on attachment 441561 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=441561&action=review > Source/WebCore/html/ImageBitmap.cpp:238 > +static ImageOrientation imageOrientationForOrientation(ImageBitmapOptions::Orientation imageBitmapOrientation, ImageOrientation imageOrientation = ImageOrientation::None) This function is confusing: 1. The name does not reveal what it converts from and what it converts to. We have ImageBitmapOptions::Orientation and ImageOrientation. So which one is "imageOrientation" and which one is "Orientation"? 2. The second name of the second parameter "imageOrientation" does not reveal what it represents. Can it be something "defaultImageOrientation"? > Source/WebCore/html/ImageBitmap.cpp:389 > + auto orientation = imageForRender->orientation(); imageForRender -> imageForRenderer
Cameron McCormack (:heycam)
Comment 10 2021-10-18 16:13:33 PDT
(In reply to Myles C. Maxfield from comment #8) > I've had to write similar code to this elsewhere. I think we should try to > push this complexity somewhere lower level. I'm not sure where, though. It might be an artifact of Image::orientation() having a default implementation that returns FromImage. Maybe it should be returning None. (I'll file a followup.)
Cameron McCormack (:heycam)
Comment 11 2021-10-18 17:12:24 PDT
(In reply to Said Abou-Hallawa from comment #9) > > Source/WebCore/html/ImageBitmap.cpp:238 > > +static ImageOrientation imageOrientationForOrientation(ImageBitmapOptions::Orientation imageBitmapOrientation, ImageOrientation imageOrientation = ImageOrientation::None) > > This function is confusing: I think you're right that the name is no longer appropriate. I'll rename. (But I guess I'll leave the other two similarly named functions, interpolationQualityForResizeQuality and alphaPremultiplicationForPremultiplyAlpha, since they're pure conversion functions.)
Cameron McCormack (:heycam)
Comment 12 2021-10-18 19:48:16 PDT
Created attachment 441678 [details] Patch for landing
Cameron McCormack (:heycam)
Comment 13 2021-10-18 19:57:04 PDT
(In reply to Cameron McCormack (:heycam) from comment #10) > (In reply to Myles C. Maxfield from comment #8) > > I've had to write similar code to this elsewhere. I think we should try to > > push this complexity somewhere lower level. I'm not sure where, though. > > It might be an artifact of Image::orientation() having a default > implementation that returns FromImage. Maybe it should be returning None. > (I'll file a followup.) Filed bug 231934.
EWS
Comment 14 2021-10-18 23:32:31 PDT
Committed r284436 (243198@main): <https://commits.webkit.org/243198@main> All reviewed patches have been landed. Closing bug and clearing flags on attachment 441678 [details].
Micah
Comment 15 2022-06-29 11:23:02 PDT
Anyone know when this will land in Safari? Currently, in Safari 15, EXIF orientations 5-8 are not handled correctly. Oddly enough, 1-4 are handled just fine. We still have to use ImageElement in Safari (instead of ImageBitmap) when rendering images to Canvas / WebGL texture to work around this bug. I'm not positive if this exact bug is tracked by this issue, but it seems to be related.
Cameron McCormack (:heycam)
Comment 16 2022-06-29 14:33:10 PDT
(In reply to Micah from comment #15) > Anyone know when this will land in Safari? This change was included in Safari 15.2. > Currently, in Safari 15, EXIF orientations 5-8 are not handled correctly. > Oddly enough, 1-4 are handled just fine. > > We still have to use ImageElement in Safari (instead of ImageBitmap) when > rendering images to Canvas / WebGL texture to work around this bug. I'm not > positive if this exact bug is tracked by this issue, but it seems to be > related. Either sounds like a related issue, or the fix for this bug wasn't complete. Could you file a new bug with a description of the issue you're seeing and CC me? Thank you.
Micah
Comment 17 2022-06-29 15:04:48 PDT
(In reply to Cameron McCormack (:heycam) from comment #16) > (In reply to Micah from comment #15) > > Anyone know when this will land in Safari? > > This change was included in Safari 15.2. > > > Currently, in Safari 15, EXIF orientations 5-8 are not handled correctly. > > Oddly enough, 1-4 are handled just fine. > > > > We still have to use ImageElement in Safari (instead of ImageBitmap) when > > rendering images to Canvas / WebGL texture to work around this bug. I'm not > > positive if this exact bug is tracked by this issue, but it seems to be > > related. > > Either sounds like a related issue, or the fix for this bug wasn't complete. > Could you file a new bug with a description of the issue you're seeing and > CC me? Thank you. Thanks Cameron! I created a new issue here: https://bugs.webkit.org/show_bug.cgi?id=242137 Turns out I was confused about EXIF orientations 1-4 working. Looks like none of them are working (except 1 of course).
Note You need to log in before you can comment on or make changes to this bug.