Android 如何在不涉及位图的情况下对图像uri应用EXIF方向?

Android 如何在不涉及位图的情况下对图像uri应用EXIF方向?,android,bitmap,uri,exif,image-rotation,Android,Bitmap,Uri,Exif,Image Rotation,我知道在位图对象上应用EXIF方向,这样做- public static Bitmap getCorrectBitmap(Bitmap bitmap, String filePath) { ExifInterface ei; Bitmap rotatedBitmap =bitmap; try { ei = new ExifInterface(filePath); int orientation =

我知道在位图对象上应用EXIF方向,这样做-

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;
    }
但是,我得到的是一些旋转图像,相机图像uri和它们对应的sd卡文件路径

如果有人向我建议一种在图像uri上应用类似EXIF方向并返回正确方向的uri的好方法,那就太好了


我不想在这个过程中涉及位图对象,因为获取图像的位图每幅图像大约需要1秒的时间。

您想要的是从旋转的位图创建一个图像文件?复制原件?你的意思是,我需要从uri创建位图,我有?我想你必须使用位图,你可以做的是构建代码以避免内存问题。另一件你可以使用的东西是好的…ffmpeg似乎有些不同。嗯…Thnx的帮助…但我终于创建了图像的缩略图…并将应用EXIF方向…希望它有帮助。