cropImage function
Crops and compresses an image, as File
.
It is used to compress the profile pictures.
Implementation
Future<File> cropImage(File imageFile) async {
print("cropping image"); //todo: remove debug print
final tempDir = await getTemporaryDirectory();
final path = tempDir.path;
int rand = new Random().nextInt(10000);
int proPicDimension = 200; //here is defined the size width of the profile pictures
Im.Image image = Im.decodeImage(imageFile.readAsBytesSync());
image = _imageSquarer(image);
image = Im.copyResize(image, proPicDimension);
print("image cropped");
imageFile = new File('$path/img_$rand.jpg')
..writeAsBytesSync(Im.encodeJpg(image, quality: 75));
return imageFile;
}