cropImageToCenterBox static method
Implementation
static Future<Uint8List?> cropImageToCenterBox(
Uint8List imageBytes, Rect calculatedRect) async {
final originalImage = img.decodeImage(imageBytes);
if (originalImage == null) return null;
final cropX = calculatedRect.left.toInt();
final cropY = calculatedRect.top.toInt();
final cropWidth = calculatedRect.width.toInt();
final cropHeight = calculatedRect.height.toInt();
final cropped = img.copyCrop(
originalImage,
x: cropX,
y: cropY,
width: cropWidth,
height: cropHeight,
);
return Uint8List.fromList(img.encodeJpg(cropped));
}