How to crop image based on Alpha in Compositor? I wonder if there is any way to crop a image based on alpha data like this:



The reason I want to do this is that I want to crop the White area of another image (of the same dimension to the Alpha image above), then stretch it to fill the whole area, or fit to other expected dimension. And this has to be done in Compositor.

For example, this is a MANUAL way to crop then fit to expected dimension:



Blend File

However, to decide the value in Crop node is not so easy in order to get rid of unwanted part. So I wonder if there is any way (math or something?) that can be smart enough to save that work.
Use this node setup:

In the texture node, you open the image you want to use as a mask, then plug the alpha output from that to the scale node's input for X and Y (the scale node's &quot;Coordinate Space&quot; is set to relative), you grab you RenderLayer and shove it in the image input for the sacle node, and finally connect that to the composite node.