editImage method
Implementation
@override
Future<MediaInfo> editImage(ImageEditRequest request) async {
imageEdits.add(request);
final error = nextImageEditError;
if (error != null) {
nextImageEditError = null;
throw error;
}
// Mirror the real ordering so a test can assert on output dimensions:
// crop, then rotate, then scale.
final source = files[request.sourcePath] ?? defaultInfo(request.sourcePath);
final crop = request.crop;
var width = crop == null
? source.width
: (crop.width * source.width).round();
var height = crop == null
? source.height
: (crop.height * source.height).round();
if (request.rotation == MonoRotation.quarterTurn ||
request.rotation == MonoRotation.threeQuarterTurns) {
(width, height) = (height, width);
}
final cap = request.maxDimension;
if (cap != null && (width > cap || height > cap)) {
final factor = cap / (width > height ? width : height);
width = (width * factor).round();
height = (height * factor).round();
}
return MediaInfo(
path: request.outputPath,
width: width,
height: height,
byteSize: 2048,
);
}