async function cropImage(imageUri, topLeftCoords, bottomRightCoords) { const { uri } = await ImageManipulator.manipulateAsync( imageUri, [ { crop: { originX: topLeftCoords.x, originY: topLeftCoords.y, width: bottomRightCoords.x - topLeftCoords.x, height: bottomRightCoords.y - topLeftCoords.y, }, }, ], { compress: 1, format: ImageManipulator.SaveFormat.JPEG } ); return uri; } export class ModelService { // ... (existing code) async classifyCroppedImages(image: ImageManipulator.ImageResult, topLeftCoords1, bottomRightCoords1, topLeftCoords2, bottomRightCoords2): Promise { const croppedImageUri1 = await cropImage(image.uri, topLeftCoords1, bottomRightCoords1); const croppedImageUri2 = await cropImage(image.uri, topLeftCoords2, bottomRightCoords2); const croppedImage1: ImageManipulator.ImageResult = await ImageManipulator.manipulateAsync( croppedImageUri1, [], { base64: true } ); const croppedImage2: ImageManipulator.ImageResult = await ImageManipulator.manipulateAsync( croppedImageUri2, [], { base64: true } ); const [predictionResponse1, predictionResponse2] = await Promise.all([ this.classifyImage(croppedImage1), this.classifyImage(croppedImage2), ]); return [predictionResponse1, predictionResponse2]; } }