Skip to content

Instantly share code, notes, and snippets.

@lucnap
Last active June 25, 2019 17:25
Show Gist options
  • Save lucnap/d4f8884b51d48d7af651bf3485fd2302 to your computer and use it in GitHub Desktop.
Save lucnap/d4f8884b51d48d7af651bf3485fd2302 to your computer and use it in GitHub Desktop.
Resizing and Padding image to keep a constant aspect ratio with ImageMagick
Resizing and Padding image to keep a constant aspect ratio with ImageMagick
This command center any given image in an area of 768x1024 and resize to fit the aspect ratio 768x1024
magick mogrify -resize 768x1024 -background "#fff" -gravity center -extent 768x1024 *Copia.jpg
Example Batch file, ResizeAndPadImage.bat
if not exist "out" mkdir out
magick mogrify -resize 768x1024 -background "#fff" -path "./out" -gravity center -extent 768x1024 %1
and use with
ResizeAndPadImage.bat "c:\example\My Image1.jpg"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment