1

I know applying EXIF orientation on the bitmap object, doing this -

public static Bitmap getCorrectBitmap(Bitmap bitmap, String filePath) {
        ExifInterface ei;
        Bitmap rotatedBitmap =bitmap;
        try {
            ei = new ExifInterface(filePath);

            int orientation = ei.getAttributeInt(ExifInterface.TAG_ORIENTATION,
                    ExifInterface.ORIENTATION_NORMAL);
            Matrix matrix = new Matrix();
            switch (orientation) {
                case ExifInterface.ORIENTATION_ROTATE_90:
                    matrix.postRotate(90);
                    break;
                case ExifInterface.ORIENTATION_ROTATE_180:
                    matrix.postRotate(180);
                    break;
                case ExifInterface.ORIENTATION_ROTATE_270:
                    matrix.postRotate(270);
                    break;
            }

            rotatedBitmap = Bitmap.createBitmap(bitmap , 0, 0, bitmap .getWidth(), bitmap .getHeight(), matrix, true);
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        return rotatedBitmap;
    }

But, what I am having is - a few rotated images (camera images) uri and their corresponding file paths (of sd card).

It will be great, if someone suggests me a good way to apply similar EXIF orientation on the image uri and getting back the correctly oriented uri.

I do not want to involve bitmap object in this process as getting bitmap of the image consumes time (about 1 second per image).

Narendra Singh
  • 3,990
  • 5
  • 37
  • 78
  • What you want is to create an image file from the rotated bitmap? make a copy of the original? – mmark May 23 '15 at 14:13
  • do you mean, I need to create bitmap from the uri, I have? – Narendra Singh May 23 '15 at 14:16
  • i think you'll have to use bitmaps, what you can do is build an [efficient](http://stackoverflow.com/questions/17169339/rotating-bitmap-causes-outofmemoryexception) code to avoid memory issues. Another thing you can use is [ffmpeg](http://superuser.com/questions/616311/ffmpeg-filter-to-rotate-image-through-arbitrary-angle) – mmark May 23 '15 at 14:34
  • Well...ffmpeg seems something different. – Narendra Singh May 23 '15 at 14:42
  • it is, but it requires a lit of bit of setup see [link](https://trac.ffmpeg.org/wiki/How%20to%20compile%20FFmpeg%20for%20Android) – mmark May 23 '15 at 14:56
  • 1
    Hmm...Thnx for the help....but I am finally creating thumbnail of the image...and will apply EXIF orientation to it...Hope it help. – Narendra Singh May 23 '15 at 15:09
  • `know applying EXIF orientation on the bitmap object, doing this`. That is nonsense as Bitmaps dont contain Exif information. What you ment to say instead is: i know how to rotate a bitmap according the Exif information of a jpg file. You moreover forgot to tell that the bitmap originates from that jpg file. Or does not it? – greenapps May 24 '15 at 12:35
  • But, I guess...you understood what I meant. – Narendra Singh May 24 '15 at 17:57

0 Answers0