Skip to content

Instantly share code, notes, and snippets.

@macmladen
Created May 16, 2024 15:42
Show Gist options
  • Save macmladen/d6f7c562b23712f9436c4aee97616904 to your computer and use it in GitHub Desktop.
Save macmladen/d6f7c562b23712f9436c4aee97616904 to your computer and use it in GitHub Desktop.
ImageMagick useful oneliners
# Take each image, (900x1600)
# crop it to 900x900 by translating x=0 and Y=350
# repage - reset canvas
# resize then to 300x300
# delay between animated frames
# cyclic loop
# all *.jpg in the directory to resulting gif
magick *.jpg -crop 900x900+0+350 +repage -resize 300x300 -delay 6 -loop 0 *.jpg animated.gif
# Further savings: -layers 'optimize' -fuzz 7%
# use -gravity [Center,South,SouthWest..] to avoid using offset
# Interesting globbing option image_{0..99}.jpg
# Resizing to banner width of 1200 for the web, reduce quality, strip meta data
magick mogrify -resize 1200 -quality 25 -strip -format jpg *.png
# Resizing to path in the current directory: -path optimised
# Resize only if width is greater than 1200: -resize "1200>"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment