transform method
Implementation
@override
Future<void> transform(MediaPipeline pipeline) async {
if (!multimediaFFIMode) {
pipeline.memory["$wandKey.src"] = image;
return;
}
if (formatHint != null &&
!isFormatReadSupportedMagick(formatHint!) &&
isFormatReadSupportedBackup(formatHint!)) {
print("Using backup loader for $formatHint to convert to PNG first");
await (img.Command()
..decodeImageFile(image.path)
..encodePng(level: 0)
..writeToFile(image.path))
.executeThread();
}
MagickWand wand = MagickWand.newMagickWand();
await wand.magickReadImage(image.path);
if (maxDim != null) {
(int, int) inSize =
(wand.magickGetImageWidth(), wand.magickGetImageHeight());
(int, int) outSize = _imageScale(inSize.$1, inSize.$2, maxDim!);
await wand.magickScaleImage(columns: outSize.$1, rows: outSize.$2);
}
pipeline.memory["$wandKey.src"] = image;
pipeline.memory[wandKey] = wand;
}