Images taken from camera being rotated 90 degrees counter-clockwise

See original GitHub issue

Current behavior

Whenever I compress an image taken straight from the camera (in portrait mode) the image gets rotated 90 degrees counter-clockwise after compressed. This happens on the physical device (in my case, a Samsung Galaxy S10 Lite), but not on the Android Emulator.

I am using react-native-image-picker (version 4.7.3) to take the images and then compressing them using react-native-compressor before upload. Using react-native-image-picker itself does not rotate the image. The problem occurs specifically on android after I use the compressor to compress the image taken from react-native-image-picker. Here is the code:

import { Image as ImageCompressor } from 'react-native-compressor';
import { launchCamera } from 'react-native-image-picker';

addImageFromCamera = async () => {
    const result = await launchCamera({
        mediaType: 'photo',
        saveToPhotos: true,
    });

    if (result.didCancel) {
        return;
    }

    const compressedImage = await ImageCompressor.compress(result.assets[0].uri, { autoCompress: true });

    return compressedImage;
}

The output is great! The image’s size is significantly reduced and the quality is still good. It is just the orientation issue bothering the users on Android(only).

Expected behavior

Compress the image keeping its original orientation.

Platform

  • Android

React Native Version

0.61.5

React Native Compressor Version

0.5.17

Reproducible Steps And Demo

  • Using an Android physical device, take an image from camera using react-native-image-picker (lauchCamera())
  • Pass the output result to react-native-compressor using the auto compression (Image.compress(Image_URI_Here, { autoCompress: true }))
  • Check the result on the React Native’s Image component or look into your phone’s file manager to see if the image had its orientation changed from portrait to landscape.

ezgif-4-c750eb23cd

Issue Analytics

  • State:open
  • Created a year ago
  • Reactions:2
  • Comments:12

github_iconTop GitHub Comments

2reactions
iphoniccommented, Jun 10, 2022

Just noticed something! The issue seems to be related with Samsung cameras. Just tested on a Motorola and image did not get rotated.

Is there any configuration I can do to my phone’s camera to get this right?

Don’t think it’s only Samsung, I am checking it on OnePlus, same. it rotates.

1reaction
Marcuspocommented, Sep 8, 2022

+1

Read more comments on GitHub >

github_iconTop Results From Across the Web

why are all of my camera pictures come out rotated 90 degrees?
I prefer to use portrait mode for pictures.. and the pictures are always 90 degrees to the "right". what's funny is that picasa...
Read more >
When i take a photo,It gets rotated 90 degrees anti clockwise
If you're opening camera through intent, the best to solve the rotation problem is to have a temporary fragment with the rotation icon...
Read more >
4.9. Rotate An Image - GIMP Documentation
Images that are taken with digital cameras sometimes need to be rotated. To do this, use Image → Transform → Rotate 90° clockwise...
Read more >
How to solve incorrect photo rotation after sync or upload
I rotated photos taken in portrait orientation 90 degrees using the photo editing feature and saved the changes. Then created a new shared...
Read more >
Resulting photo is rotated 90° counter-clockwise #263 - GitHub
The photo is taken but rotated 90° counter-clockwise. What did you expect? I expected the photo to be taken in the same orientation...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found