'Instance is disposed' error when trying to perform circular crop. #132
Answered
by
daoanhthanh
daoanhthanh
asked this question in
Q&A
-
As the title, this is my original CLI command: magick input.jpeg \
+repage -crop 2848x2848+560+0! \
-auto-orient -alpha on \
\( +clone -channel a -evaluate \
multiply 0 +channel -fill white \
-draw 'circle 1424.0,1424.0 0.0,1424.0' \) \
-compose DstIn -composite -resize 300 output.png I want to do it using wasm lib. I followed this document and this is my function: changeImage(image: IMagickImage): void {
image.crop(
new MagickGeometry(
this.x_cor,
this.y_cor,
this.croppedWidth,
this.croppedHeight
)
);
const cloned = image.clone((cl) => {
cl.evaluate(Channels.Alpha, EvaluateOperator.Multiply, 0);
const circle = new DrawableRoundRectangle(
0,
0,
this.croppedHeight,
this.croppedWidth,
this.croppedHeight / 2,
this.croppedWidth / 2
);
cl.alpha(AlphaOption.Opaque);
cl.draw(circle);
return cl;
});
image.compositeGravity(cloned, Gravity.Center);
image.autoOrient();
image.resize(this.resizedWidth, this.resizedHeight);
} I got an error when execute this code:
Can someone please explain why? Is this my incorrect implementation or something else? |
Beta Was this translation helpful? Give feedback.
Answered by
daoanhthanh
Dec 21, 2023
Replies: 1 comment 3 replies
-
You cannot return the image from |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thank you, it works with some modifications. This is the final code: