compress static method
Implementation
static Future<File?> compress({
required File image,
CompressParams compressParams = defaultCompress,
}) async {
var dir = await getTemporaryDirectory();
var targetPath = '${dir.path}/compressed_${DateTime.now().millisecondsSinceEpoch}.jpg';
var compressedFile = await FlutterImageCompress.compressAndGetFile(
image.absolute.path,
targetPath,
quality: compressParams.quality,
minHeight: compressParams.targetHeight,
minWidth: compressParams.targetWidth,
);
if (compressedFile == null) {
debugPrint('Compression failed');
return null;
}
return File(compressedFile.path);
}