Auto rotate HEIF images

master
M66B 1 week ago
parent 1d16362080
commit fe658120f0

@ -5688,7 +5688,7 @@ public class FragmentCompose extends FragmentBase {
(!resize_width_only && options.outHeight / factor > resize))
factor *= 2;
Matrix rotation = ("image/jpeg".equals(attachment.type) ? ImageHelper.getImageRotation(file) : null);
Matrix rotation = ImageHelper.getImageRotation(attachment.type, file);
Log.i("Image type=" + attachment.type + " factor=" + factor + " rotation=" + rotation);
if (factor > 1 || rotation != null) {
options.inJustDecodeBounds = false;

@ -925,7 +925,7 @@ class ImageHelper {
}
if (bm != null) {
Matrix rotation = getImageRotation(file);
Matrix rotation = getImageRotation(mimeType, file);
if (rotation != null) {
Bitmap rotated = Bitmap.createBitmap(bm, 0, 0, bm.getWidth(), bm.getHeight(), rotation, true);
bm.recycle();
@ -953,10 +953,11 @@ class ImageHelper {
return drawable;
}
static Matrix getImageRotation(File file) {
static Matrix getImageRotation(String mimeType, File file) {
try {
ExifInterface exif = new ExifInterface(file);
int orientation = exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_UNDEFINED);
Log.i("Image Exif orientation=" + orientation + " type=" + mimeType);
Matrix matrix = new Matrix();
switch (orientation) {

Loading…
Cancel
Save