cropperjs icon indicating copy to clipboard operation
cropperjs copied to clipboard

Cropper shows image squished if image has non zero EXIF rotation and application uses image-orientation: none

Open Egor-Chib opened this issue 4 years ago • 4 comments

If image EXIF include rotation and application uses "image-orientation: none" then image will be shown in cropper squished, cropper messing up / swapping image height and width. Windows 10, Browsers: FF & Chrome

In our application we use image, img { image-orientation: none; } We use images with and without EXIF information. EXIF information sometimes includes image rotation - this is the case when we have trouble. Images without EXIF and images with EXIF but without rotation seems to be ok,

We and our customers have this problem and it is critical for our business.

I have it debugged.

The problem caused by using naturalWidth and naturalHeight HTML5 image properties.

This is one of the consequences of changed default value of "image-orientation" style attribute from "none" to "from-image". Browsers FF and Chromium.

Now when cropper requesting "natural" attributes of the image with non zero rotation in EXIF and image under "image-orientation: none" browser provide wrong information.

We used this image file for testing: Frm Essense

Expected behavior: image appear in cropper editor with correct aspect ratio/proportions

Actual behavior: on screenshot you can see, that cropper assign width to height and height to width, image looks super wide, squished,

image-2020-06-10-10-09-25-624

Egor-Chib avatar Jun 18 '20 23:06 Egor-Chib

Currently, for browsers that support the image-orientation property, you should NOT set it to none, but from-image.

fengyuanchen avatar Jun 21 '20 08:06 fengyuanchen

Or you might remove the Exif Orientation info before applying to the Cropper.js.

fengyuanchen avatar Jun 21 '20 08:06 fengyuanchen

Thanks. You suggested good bug workaround and I am aware of it.

Would you, please, advise if there are some ETA for this bug fix?

Egor-Chib avatar Jun 22 '20 04:06 Egor-Chib

I still have not a good idea or solution for this currently. I still search for a well cross-browser solution about image-orientation. Thanks!

fengyuanchen avatar Jun 25 '20 03:06 fengyuanchen