From 073f6bbd7dbe21bc73dd1e54dcc569bf8dc76ec1 Mon Sep 17 00:00:00 2001 From: Krille Fear Date: Wed, 1 Dec 2021 20:44:59 +0100 Subject: [PATCH] change: Do not compress very small images --- lib/pages/chat/send_file_dialog.dart | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/pages/chat/send_file_dialog.dart b/lib/pages/chat/send_file_dialog.dart index 37ea7476..3b44680e 100644 --- a/lib/pages/chat/send_file_dialog.dart +++ b/lib/pages/chat/send_file_dialog.dart @@ -26,9 +26,14 @@ class _SendFileDialogState extends State { bool origImage = false; bool _isSending = false; + /// Images smaller than 20kb don't need compression. + static const int minSizeToCompress = 20 * 1024; + Future _send() async { var file = widget.file; - if (file is MatrixImageFile && !origImage) { + if (file is MatrixImageFile && + !origImage && + file.bytes.length > minSizeToCompress) { file = await file.resizeImage(quality: 40, max: 1200); } await widget.room.sendFileEventWithThumbnail(file); @@ -53,7 +58,6 @@ class _SendFileDialogState extends State { fit: BoxFit.contain, ), ), - Text(widget.file.name), Row( children: [ Checkbox(