-
Notifications
You must be signed in to change notification settings - Fork 687
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
[css-images] image-orientation and canvas drawImage #4666
Comments
From my testing in Chrome Canary yesterday, it looks like the Testing a recent WebKit build, it's looking at the I think it makes more sense to look at the |
Some tests: https://mcc.id.au/2020/image-orientation/ |
Hi, I'm the author of a JavaScript Image Loading/Manipulation library (see also the previously referenced issue) and I noticed that there's another variable in If the image and canvas elements are constructed outside of the DOM and the canvas only added to the DOM after the For browser-based image manipulation libraries, it's important to be able to change the One use case for this is to be able to auto-rotate (based on EXIF data) and save the resulting image without keeping the meta data. Currently, the situation looks like the following:
To illustrate this better, I took the liberty to extend your test example @heycam with the out-of-DOM behaviors (hot-linking your example image) - hope that is acceptable: At the moment, the only way I see to properly detect if an out-of-DOM created canvas element has been rotated by the browser is to use a (minimal) test image, which is less than ideal. I hope this provides some context from the JS library author view. |
Resolves #97 See also: w3c/csswg-drafts#4666
Some browsers (at least recent Chrome versions) automatically take image metadata into account when drawing images into a canvas. There seem to be no way to prevent that behavior, and the only way to detect it seems to compare with a known image. See: w3c/csswg-drafts#4666 Solution adapted from: blueimp/JavaScript-Load-Image@1e4df70
Some browsers (at least recent Chrome versions) automatically take image metadata into account when drawing images into a canvas. There seem to be no way to prevent that behavior, and the only way to detect it seems to compare with a known image. See: w3c/csswg-drafts#4666 Solution adapted from: blueimp/JavaScript-Load-Image@1e4df70
More questions on https://drafts.csswg.org/css-images/#the-image-orientation
As of Canary version 81.0.4017.0 chromium supports the image-orientation property for all images in all locations, defaulting to the "from-image" value but also supporting "none" to turn off exif image-orientation.
In numerous cases where there is not yet a code path to access the CSS property, chromium will use "from-image". Right now that means that canvas drawImage calls will always respect the exif orientation.
Assuming we support image-orientation: none for drawImage, which element's image-orientation property should take priority when there is a conflict between the source element and the canvas element? I argue for the source but welcome feedback.
Given Safari does not support "none", should chromium just always use image-orientation: from-image in this situation?
There are some other similar cases: when an image is dragged and maybe when WebGL binds an image as texture. In all cases I argue that we respect the source's preferred orientation as that will avoid the image appearing to rotate when dragged or copied.
The text was updated successfully, but these errors were encountered: