Always convert HEIC images to JPEG.
This pr changes the behavior of sending HEIC images to always convert them to JPEG. This conversion is required to support image inline viewing accross different devices and operating systems. This follows the same strategy as on IOS: https://github.com/signalapp/Signal-iOS/pull/2511 Fixes: https://github.com/signalapp/Signal-iOS/issues/4374 & https://github.com/signalapp/Signal-Android/issues/9395
This commit is contained in:
parent
11d17f7496
commit
4712833853
2 changed files with 13 additions and 0 deletions
|
@ -145,6 +145,10 @@ public final class AttachmentCompressionJob extends BaseJob {
|
|||
if (!constraints.isSatisfied(context, attachment)) {
|
||||
throw new UndeliverableMessageException("Size constraints could not be met on video!");
|
||||
}
|
||||
} else if (MediaUtil.isHeic(attachment)) {
|
||||
MediaStream converted = getResizedMedia(context, attachment, constraints);
|
||||
attachmentDatabase.updateAttachmentData(attachment, converted, false);
|
||||
attachmentDatabase.markAttachmentAsTransformed(attachmentId);
|
||||
} else if (constraints.isSatisfied(context, attachment)) {
|
||||
if (MediaUtil.isJpeg(attachment)) {
|
||||
MediaStream stripped = getResizedMedia(context, attachment, constraints);
|
||||
|
|
|
@ -49,6 +49,7 @@ public class MediaUtil {
|
|||
|
||||
public static final String IMAGE_PNG = "image/png";
|
||||
public static final String IMAGE_JPEG = "image/jpeg";
|
||||
public static final String IMAGE_HEIC = "image/heic";
|
||||
public static final String IMAGE_WEBP = "image/webp";
|
||||
public static final String IMAGE_GIF = "image/gif";
|
||||
public static final String AUDIO_AAC = "audio/aac";
|
||||
|
@ -219,6 +220,10 @@ public class MediaUtil {
|
|||
return isJpegType(attachment.getContentType());
|
||||
}
|
||||
|
||||
public static boolean isHeic(Attachment attachment) {
|
||||
return isHeicType(attachment.getContentType());
|
||||
}
|
||||
|
||||
public static boolean isImage(Attachment attachment) {
|
||||
return isImageType(attachment.getContentType());
|
||||
}
|
||||
|
@ -247,6 +252,10 @@ public class MediaUtil {
|
|||
return !TextUtils.isEmpty(contentType) && contentType.trim().equals(IMAGE_JPEG);
|
||||
}
|
||||
|
||||
public static boolean isHeicType(String contentType) {
|
||||
return !TextUtils.isEmpty(contentType) && contentType.trim().equals(IMAGE_HEIC);
|
||||
}
|
||||
|
||||
public static boolean isFile(Attachment attachment) {
|
||||
return !isGif(attachment) && !isImage(attachment) && !isAudio(attachment) && !isVideo(attachment);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue