1
0
Fork 0
mirror of https://github.com/M66B/FairEmail.git synced 2025-01-19 13:48:58 +00:00

Fixed resize compression format

This commit is contained in:
M66B 2023-11-03 15:52:45 +01:00
parent 4b09664a5a
commit b867e38530

View file

@ -5212,10 +5212,18 @@ public class FragmentCompose extends FragmentBase {
resized = rotated;
}
Bitmap.CompressFormat format;
if ("image/jpeg".equals(attachment.type))
format = Bitmap.CompressFormat.JPEG;
else if ("image/png".equals(attachment.type))
format = Bitmap.CompressFormat.PNG;
else if ("image/webp".equals(attachment.type))
format = Bitmap.CompressFormat.WEBP;
else
throw new IllegalArgumentException("Invalid format type=" + attachment.type);
File tmp = new File(file.getAbsolutePath() + ".tmp");
try (OutputStream out = new BufferedOutputStream(new FileOutputStream(tmp))) {
Bitmap.CompressFormat format = ("image/jpeg".equals(attachment.type)
? Bitmap.CompressFormat.JPEG : Bitmap.CompressFormat.PNG);
if (!resized.compress(format, REDUCED_IMAGE_QUALITY, out))
throw new IOException("compress");
} catch (Throwable ex) {