mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-21 00:59:49 +01:00
Fix large images sometimes not respecting EXIF orientation.
Fixes #11614
This commit is contained in:
committed by
Greyson Parrelli
parent
ac90eeb42f
commit
49a1a4a123
@@ -244,16 +244,19 @@ public class BitmapUtil {
|
||||
return options;
|
||||
}
|
||||
|
||||
public static int getExifOrientation(ExifInterface exif) {
|
||||
return exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_UNDEFINED);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static Pair<Integer, Integer> getExifDimensions(InputStream inputStream) throws IOException {
|
||||
ExifInterface exif = new ExifInterface(inputStream);
|
||||
int width = exif.getAttributeInt(ExifInterface.TAG_IMAGE_WIDTH, 0);
|
||||
int height = exif.getAttributeInt(ExifInterface.TAG_IMAGE_LENGTH, 0);
|
||||
public static Pair<Integer, Integer> getExifDimensions(ExifInterface exif) {
|
||||
int width = exif.getAttributeInt(ExifInterface.TAG_IMAGE_WIDTH, 0);
|
||||
int height = exif.getAttributeInt(ExifInterface.TAG_IMAGE_LENGTH, 0);
|
||||
if (width == 0 || height == 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
int orientation = exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, 0);
|
||||
int orientation = getExifOrientation(exif);
|
||||
if (orientation == ExifInterface.ORIENTATION_ROTATE_90 ||
|
||||
orientation == ExifInterface.ORIENTATION_ROTATE_270 ||
|
||||
orientation == ExifInterface.ORIENTATION_TRANSVERSE ||
|
||||
|
||||
@@ -17,6 +17,7 @@ import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.annotation.RequiresApi;
|
||||
import androidx.annotation.WorkerThread;
|
||||
import androidx.exifinterface.media.ExifInterface;
|
||||
|
||||
import com.bumptech.glide.load.engine.DiskCacheStrategy;
|
||||
import com.bumptech.glide.load.resource.gif.GifDrawable;
|
||||
@@ -189,7 +190,7 @@ public class MediaUtil {
|
||||
try {
|
||||
if (MediaUtil.isJpegType(contentType)) {
|
||||
attachmentStream = PartAuthority.getAttachmentStream(context, uri);
|
||||
dimens = BitmapUtil.getExifDimensions(attachmentStream);
|
||||
dimens = BitmapUtil.getExifDimensions(new ExifInterface(attachmentStream));
|
||||
attachmentStream.close();
|
||||
attachmentStream = null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user