Get image rotation using filedescriptor and parcelfiledescriptor in android from gallery

I want to get an image with a device higher than Android kitkat. I am currently using filedescriptor and parcelfiledescriptor to get the image. I get the image successfully but rotated. Since the image is stored in google drive, I cannot use the input stream directly. How can I solve this? (I know that image data is usually stored in exif, but if I try to get exif data then rotation is always 0) I also tried using lib: https://github.com/coomar2841/image-chooser-library , but i am getting the same problem here.

           ParcelFileDescriptor parcelFileDescriptor;
        try {
            parcelFileDescriptor = activity.getContentResolver().openFileDescriptor(selectedImage, "r");

            FileDescriptor fileDescriptor = parcelFileDescriptor.getFileDescriptor();

            Bitmap image = BitmapFactory.decodeFileDescriptor(fileDescriptor);
            image = ExifUtil.rotateBitmap(selectedImagePath, image);
            parcelFileDescriptor.close();
            if (cropCircle) {
                imageView.setImageBitmap(ImageUtils.cutCircle(image));
            } else {
                imageView.setImageBitmap(image);
            }
            return image;
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

      

+3
android image-rotation gallery drive google-photos


source to share


No one has answered this question yet

Check out similar questions:

1296
Reloading activity on android rotation
1188
How do I get the build / version number of your Android app?
1169
Is there a way to get the source code from the APK file?
1039
Get current time and date on Android
960
How to rotate the screen of Android emulator?
882
Static way to get "Context" in Android?
251
Get / Select Image from Built-in Gallery App for Android
167
androids select images from gallery
4
Read EXIF ​​data from image using Picasso in android
1
Download Image and Save Exif Data to Android



All Articles
Loading...
X
Show
Funny
Dev
Pics