Skip to content

Instantly share code, notes, and snippets.

@chimanaco
Last active December 24, 2020 18:37
Show Gist options
  • Save chimanaco/78e5f148c007ab1a0ea650907f71c8f8 to your computer and use it in GitHub Desktop.
Save chimanaco/78e5f148c007ab1a0ea650907f71c8f8 to your computer and use it in GitHub Desktop.
ImageMagick

Use magick convert instead of convert in ImageMagick7 on Windows if you don't add change a PATH.

Resize to 512x512 in a 'square' folder

$ magick mogrify -resize 512x512 *.jpg -path ../512 *.jpg

convert all jpg(1280x720) to 720x720 in a 'square' folder

$ magick mogrify convert *.jpg -crop 720x720+280+0 -path ../square *.jpg $ magick mogrify -gravity center -crop 720x720+0+0 -path ../square *.png

Divide file into 2 files (left and right)

Single file

$ magick 03.tif -crop 50%x100% +repage splitleftout03_%02d.jpg

All files in the directory

$ magick *.tif -crop 50%x100% +repage -set filename:fname %t_half +adjoin split%[filename:fname]_%02d.jpg

Convert a file to desired with keeping its original aspect

$ magick convert input.jpg -resize [desired width] output.jpg

Convert a file to desired with keeping its original aspect

$ magick convert *.* -resize 1920 w5-%01d.png

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