Skip to content

Instantly share code, notes, and snippets.

@deepakpk009
Created August 13, 2017 09:33
Show Gist options
  • Save deepakpk009/97fa868a398bfd5dc4468037cdc8ace8 to your computer and use it in GitHub Desktop.
Save deepakpk009/97fa868a398bfd5dc4468037cdc8ace8 to your computer and use it in GitHub Desktop.
batch resize images in a folder
Use Imagemagick's batch tool, mogrify.
This takes most of the same arguments.
To scale the longest size down to 300px, we can offer -resize "300x300>".
For safety's sake I've also got this saving the new images into a subdirectory rather than overwriting.
# assuming you're in the directory of images
mkdir resized
mogrify -resize "300x300>" -path resized *.jpg
The ">" means that It will only resize if the image is bigger than the given size.
I understand from this page that when giving a size in this fashion 300x300,
that this will automatically make imagemagic fit the image in this size.
I thought that if I you to do something similar that one side would get scaled up to fit the given size
Link: https://askubuntu.com/questions/728832/i-would-like-to-batch-re-size-images-in-a-terminal
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment