Donaldcwl / browser-image-compression

Image compression in web browser
MIT License
1.31k stars 161 forks source link

Images shrink and flip in the wrong orientation on some Android devices #189

Open ysabri opened 1 year ago

ysabri commented 1 year ago

We've been encountering this weird bug on some devices where this happens to images:

Landscape3-rte0bz

This was the Landscape_3 image from the https://github.com/recurser/exif-orientation-examples repo

The two devices we know this happens on are Xiaomi and Huawei ones and I was able to reproduce this reliably on a Huawei P30.

I don't understand how or why this happens exactly and it also happens with PNGs (I wasn't able to get the original files).

When I set the exifOrientation: 1 in the options, it fixes the issue, but I don't want to do that since I would like it if we can respect the orientation of the images the user uploads.

This is another image that this happens to as well and based on the software I use (InfraView), it doesn't contain exif information:

Laptop_with_code

The result after compression:

Laptopwithcode-rte1xi

ysabri commented 1 year ago

Hi @Donaldcwl,

I understand if you aren't able to look at this, I can help.

Before I try, can you please give me your thoughts about it? Where should I start and what to keep in mind while doing so. I can reliably replicate this through devices on browserstack, so I just need some direction on what to do or look for to figure out the root cause.

dcruz1990 commented 1 year ago

Do you still having this issue?

ysabri commented 1 year ago

@dcruz1990 Not after I hardcoded the exifOrientation to 1.

I don't know if that is a good solution though