Merge "Use a ExifInterface ctor with a file descriptor as a parameter"

This commit is contained in:
Ray Essick
2023-03-20 22:50:05 +00:00
committed by Gerrit Code Review

View File

@@ -49,6 +49,7 @@ import com.android.internal.util.ArrayUtils;
import libcore.io.IoUtils; import libcore.io.IoUtils;
import java.io.File; import java.io.File;
import java.io.FileInputStream;
import java.io.IOException; import java.io.IOException;
import java.util.Arrays; import java.util.Arrays;
import java.util.Comparator; import java.util.Comparator;
@@ -255,17 +256,19 @@ public class ThumbnailUtils {
// get orientation // get orientation
if (MediaFile.isExifMimeType(mimeType)) { if (MediaFile.isExifMimeType(mimeType)) {
exif = new ExifInterface(file); try (FileInputStream is = new FileInputStream(file)) {
switch (exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, 0)) { exif = new ExifInterface(is.getFD());
case ExifInterface.ORIENTATION_ROTATE_90: switch (exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, 0)) {
orientation = 90; case ExifInterface.ORIENTATION_ROTATE_90:
break; orientation = 90;
case ExifInterface.ORIENTATION_ROTATE_180: break;
orientation = 180; case ExifInterface.ORIENTATION_ROTATE_180:
break; orientation = 180;
case ExifInterface.ORIENTATION_ROTATE_270: break;
orientation = 270; case ExifInterface.ORIENTATION_ROTATE_270:
break; orientation = 270;
break;
}
} }
} }