resizeImage method
Resize the image to a specific factor
Implementation
Future resizeImage(File file, num resizeFactor) async {
final bytes = file.readAsBytesSync();
final buffer = await ImmutableBuffer.fromUint8List(bytes);
final descriptor = await ImageDescriptor.encoded(buffer);
final imageWidth = descriptor.width;
assert(
imageWidth > 0,
'Please make sure you are using an image that is not corrupt or too small',
);
final targetWidth = (imageWidth * resizeFactor).round();
return _compressImage(file, targetWidth);
}