5

I want to get an image with a device higher then android kitkat. Currently I use the filedescriptor and parcelfiledescriptor to get the image. I get the image succesfully, but rotated. As the image is stored on google drive I can't use the inputstream directly. How can I solve this? (I know image data is usually stored in exif but if I try to get exif data the rotation is always 0) I've also tried using the lib: https://github.com/coomar2841/image-chooser-library but I get the same issue 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();
        }
2
  • 2
    Did you ever figure this out? How to get the rotation when you have a FileDescriptor? Commented Jan 16, 2016 at 16:06
  • I've been using Picasso ever since and given up ;)
    – jobbert
    Commented Jan 18, 2016 at 8:47

0