diff --git a/lib/services/storage_service.dart b/lib/services/storage_service.dart index 73c3707..8cafb98 100644 --- a/lib/services/storage_service.dart +++ b/lib/services/storage_service.dart @@ -113,6 +113,12 @@ class StorageService { static Future _compressImage(File source) async { final bytes = await source.readAsBytes(); + return compute(_compressImageBytes, bytes); + } + + /// Performs CPU-intensive image decoding, resizing, and JPEG encoding. + /// Runs in a background isolate via [compute] to avoid blocking the UI thread. + static Uint8List _compressImageBytes(Uint8List bytes) { final decoded = img.decodeImage(bytes); if (decoded == null) { throw Exception('Invalid image file.');