diff --git a/mobile/apps/photos/lib/ui/viewer/file/zoomable_image.dart b/mobile/apps/photos/lib/ui/viewer/file/zoomable_image.dart index f29315a2f2..85e4d2fb4c 100644 --- a/mobile/apps/photos/lib/ui/viewer/file/zoomable_image.dart +++ b/mobile/apps/photos/lib/ui/viewer/file/zoomable_image.dart @@ -410,13 +410,18 @@ class _ZoomableImageState extends State { precacheImage( imageProvider, context, - onError: (exception, _) async { - _logger - .info(exception.toString() + ". Filename: ${_photo.displayName}"); + onError: (exception, s) async { if (exception.toString().contains( - "Codec failed to produce an image, possibly due to invalid image data", - )) { - unawaited(_loadInSupportedFormat(file)); + "Codec failed to produce an image, possibly due to invalid image data", + ) || + exception.toString().contains( + "Could not decompress image.", + )) { + unawaited(_loadInSupportedFormat(file, e)); + } else { + _logger.warning( + "Failed to load image ${_photo.displayName} with error: $exception", + ); } }, ).then((value) { @@ -471,8 +476,13 @@ class _ZoomableImageState extends State { bool _isGIF() => _photo.displayName.toLowerCase().endsWith(".gif"); - Future _loadInSupportedFormat(File file) async { - _logger.info("Compressing ${_photo.displayName} to viewable format"); + Future _loadInSupportedFormat( + File file, + Object unsupportedErr, + ) async { + _logger.info( + "Compressing ${_photo.displayName} to viewable format due to $unsupportedErr", + ); _convertToSupportedFormat = true; Uint8List? compressedFile; @@ -492,7 +502,11 @@ class _ZoomableImageState extends State { quality: 85, ); } else { - compressedFile = await FlutterImageCompress.compressWithFile(file.path); + compressedFile = await FlutterImageCompress.compressWithFile( + file.path, + minHeight: 8000, + minWidth: 8000, + ); } if (compressedFile != null) {