Skip to main content
Question

How to crop/mask images in a plugin?

  • December 22, 2022
  • 1 reply
  • 952 views

Nathan_Huesmann

I need to essentially crop an image to the dimensions of a rectangle and can’t seem to figure out how. I’ll add some photos for an example.

Here I have the image and I have the Rectangle object:
Screen Shot 2022-12-22 at 10.33.44 AM

I need to be able to programmatically crop the image to the dimensions of the Rectangle object and then get a PNG of the cropped image, essentially creating a mask of the two. Is this possible? Or do I need to be cropping in the UI via the browser canvas?

1 reply

tank666
  • 4858 replies
  • December 23, 2022

Group both layers and then set your rectangle as a mask.

node.isMask = true
figma.com

Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings