Skip to content

'Instance is disposed' error when trying to perform circular crop. #132

Answered by daoanhthanh
daoanhthanh asked this question in Q&A
Discussion options

You must be logged in to vote

Thank you, it works with some modifications. This is the final code:

doCircularCrop(image: IMagickImage): void {
    image.crop(
      new MagickGeometry(
        this.x_cor,
        this.y_cor,
        this.croppedWidth,
        this.croppedHeight
      )
    );

    image.autoOrient();

    // Enable alpha channel
    image.alpha(AlphaOption.On);

    // Create a clone of the image for further processing
    image.clone((clone) => {
      // Set the alpha channel of the clone to 0
      clone.evaluate(Channels.Alpha, EvaluateOperator.Multiply, 0);

      // Create a round region to crop
      const circle = new DrawableRoundRectangle(
        0,
        0,
        this.croppedHeight,

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@daoanhthanh
Comment options

@dlemstra
Comment options

@daoanhthanh
Comment options

Answer selected by daoanhthanh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants