diff --git a/lib/src/room.dart b/lib/src/room.dart index d09581b..3be3291 100644 --- a/lib/src/room.dart +++ b/lib/src/room.dart @@ -478,7 +478,9 @@ class Room { Event inReplyTo, Map info, bool waitUntilSent = false, - int thumbnailSize = Client.defaultThumbnailSize, + int thumbnailMaxWidth = 800, + int thumbnailMaxHeight = 600, + int thumbnailQuality = 50, }) async { Image fileImage; Image thumbnailImage; @@ -507,7 +509,11 @@ class Room { thumbnailPathParts.last = 'thumbnail_' + thumbnailPathParts.last + '.jpg'; final thumbnailPath = thumbnailPathParts.join('/'); thumbnail = MatrixFile(bytes: file.bytes, path: thumbnailPath); - await thumbnail.resize(width: thumbnailSize); + await thumbnail.resize( + width: thumbnailMaxWidth, + height: thumbnailMaxHeight, + quality: thumbnailQuality, + ); fileImage = decodeImage(file.bytes.toList()); thumbnailImage = decodeImage(thumbnail.bytes.toList()); } diff --git a/lib/src/utils/matrix_file.dart b/lib/src/utils/matrix_file.dart index fd4a57a..93c8722 100644 --- a/lib/src/utils/matrix_file.dart +++ b/lib/src/utils/matrix_file.dart @@ -13,7 +13,11 @@ class MatrixFile { /// given width and height. Otherwise returns false. /// At least width or height must be set! /// The bytes will be encoded as jpg. - Future resize({int width, int height}) async { + Future resize({ + int width, + int height, + int quality = 50, + }) async { if (width == null && height == null) { throw ('At least width or height must be set!'); } @@ -24,7 +28,7 @@ class MatrixFile { return false; } final resizedImage = copyResize(image, width: width, height: height); - bytes = encodeJpg(resizedImage, quality: 10); + bytes = encodeJpg(resizedImage, quality: quality); return true; }