Skip to content

Instantly share code, notes, and snippets.

@db0company
Created April 26, 2021 12:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save db0company/347683af2a3b2ccf552812a947442ebe to your computer and use it in GitHub Desktop.
Save db0company/347683af2a3b2ccf552812a947442ebe to your computer and use it in GitHub Desktop.
Crop an image using a mask

If the image has no transparency

convert src.png mask.png -alpha off -compose copy_opacity -composite result.png

Example

If the image has some transparency

compose Dst_In \( mask.png -alpha copy \) src.png -alpha Set -composite PNG32:result.png

Example

I didn't figure out how to keep colors

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment