Skip to content

Instantly share code, notes, and snippets.

@juliendargelos
Last active November 20, 2025 13:04
Show Gist options
  • Select an option

  • Save juliendargelos/d9a08e693dfcdab80d28dd609b717536 to your computer and use it in GitHub Desktop.

Select an option

Save juliendargelos/d9a08e693dfcdab80d28dd609b717536 to your computer and use it in GitHub Desktop.
Imagemagick commands that trims transparent pixels from an image.
# Trim a single "input.png" image and save to "output.png"
magick input.png -trim +repage output.png
# Trim a single "image.png" image and overwrite the original file (based on @enijar comment)
mogrify -trim +repage image.png
# Trim and overwrite all png images from the working directory (based on @enijar comment)
mogrify -trim +repage *.png
@j4hangir
Copy link

Pretty leet, especially mogrify 👍

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