do not compress/resize images with strange aspect ratios. fixes #3188
This commit is contained in:
parent
b759cf902d
commit
70845c5e95
|
@ -687,6 +687,18 @@ public class FileBackend {
|
|||
updateFileParams(message);
|
||||
}
|
||||
|
||||
public boolean unusualBounds(Uri image) {
|
||||
try {
|
||||
BitmapFactory.Options options = new BitmapFactory.Options();
|
||||
options.inJustDecodeBounds = true;
|
||||
BitmapFactory.decodeStream(mXmppConnectionService.getContentResolver().openInputStream(image), null, options);
|
||||
float ratio = (float) options.outHeight / options.outWidth;
|
||||
return ratio > (21.0f / 9.0f) || ratio < (9.0f / 21.0f);
|
||||
} catch (Exception e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private int getRotation(File file) {
|
||||
return getRotation(Uri.parse("file://" + file.getAbsolutePath()));
|
||||
}
|
||||
|
|
|
@ -504,7 +504,8 @@ public class XmppConnectionService extends Service {
|
|||
|
||||
if ("never".equals(compressPictures)
|
||||
|| ("auto".equals(compressPictures) && getFileBackend().useImageAsIs(uri))
|
||||
|| (mimeType != null && mimeType.endsWith("/gif"))) {
|
||||
|| (mimeType != null && mimeType.endsWith("/gif"))
|
||||
|| getFileBackend().unusualBounds(uri)) {
|
||||
Log.d(Config.LOGTAG, conversation.getAccount().getJid().asBareJid() + ": not compressing picture. sending as file");
|
||||
attachFileToConversation(conversation, uri, mimeType, callback);
|
||||
return;
|
||||
|
|
Loading…
Reference in New Issue