compressImage method Null safety
compress an Image pic
and pass it to a callback
.
Implementation
static void compressImage(Uint8List pic, Function callback) async {
img.Image tempFile = img.decodeImage(List.from(pic))!;
tempFile = img.copyResize(
tempFile,
width: tempFile.height > tempFile.width ? -1 : 800,
height: tempFile.height > tempFile.width ? 800 : -1,
);
// convert back to bytes
callback(img.encodeJpg(tempFile, quality: 50));
}