wandTransform method

  1. @override
Future<void> wandTransform(
  1. MediaPipeline pipeline,
  2. MagickWand wand
)
override

Implementation

@override
Future<void> wandTransform(MediaPipeline pipeline, MagickWand wand) async {
  File src = pipeline.memory["$wandKey.src"];
  File srcRgba = File("${src.path.split(Platform.pathSeparator).last}.rgba");
  wand.magickSetImageInterpolateMethod(
      PixelInterpolateMethod.NearestInterpolatePixel);
  wand.magickSetImageFormat("RGBA");
  (int, int) inSize =
      (wand.magickGetImageWidth(), wand.magickGetImageHeight());
  (int, int) outSize = _forceScaleImage(inSize.$1, inSize.$2, forceDim);
  await wand.magickScaleImage(columns: outSize.$1, rows: outSize.$2);
  await wand.magickWriteImage(srcRgba.path);
  pipeline.memory["$wandKey.thumbhash"] = base64.encode(
      rgbaToThumbHash(outSize.$1, outSize.$2, await srcRgba.readAsBytes()));
  await srcRgba.delete();
  onThumbHash(pipeline.memory["$wandKey.thumbhash"]);
}