react-native-image-resizer icon indicating copy to clipboard operation
react-native-image-resizer copied to clipboard

Android: get EXIF orientation from content:// URI on r24+ (#86)

Open ge0rg opened this issue 4 years ago • 1 comments

Android has restricted access to the file:// URIs underlying a shared content URI a while ago. I'm not sure when exactly, and my google-fu is weak tonight.

On the other hand, they introduced ExifInterface(InputStream) in r24. This can be used even when we do not have permissions / access to the original file:// URI that the content:// URI resolves to.

So if we are on Android r24+, we use this new API to obtain the EXIF image orientation and to fix portraits being sideways.

ge0rg avatar Feb 15 '21 16:02 ge0rg

I also vote for this to be merged. It fixes really annoying long standing bug. Current createResizedImage() and other methods relying on getOrientation should behave consistent and predictable on all android versions.

mikekudzin avatar Aug 07 '21 20:08 mikekudzin

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Sep 01 '22 18:09 stale[bot]

Is there anything preventing you from merging this? This is a huge UX issue for app users, as camera images end up surprisingly rotated when scaled/cropped.

It looks like a few days ago, all the project code was shuffled around into a new package name / directory structure and indentation scheme, which prevented the old one from applying. I've now updated the PR to work against current master.

ge0rg avatar Sep 02 '22 09:09 ge0rg

Hi @ge0rg ,

We lacked the time to manage this repo (yes, it's been while).

I'm the maintainer now. I see that your topic is still relevant.

I will review you PR this WE 🙏!

Can you just help me and provide me a repro steps to test it properly 😄

taboulot avatar Sep 03 '22 08:09 taboulot

I'm sorry, I don't have a minimal repro example, but if you take a portrait picture on any recent Android phone (I thin some time around Android 10), and resize it using rn-ir, it will end up rotated by 90°.

ge0rg avatar Sep 04 '22 19:09 ge0rg