mirror of
https://github.com/M66B/FairEmail.git
synced 2026-04-03 23:56:07 +02:00
Auto rotate HEIF images
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user