Skip to content

Instantly share code, notes, and snippets.

@sodonnell
Created February 8, 2018 19:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sodonnell/9f2c1900efe48e7ea1de310cfaef0ac0 to your computer and use it in GitHub Desktop.
Save sodonnell/9f2c1900efe48e7ea1de310cfaef0ac0 to your computer and use it in GitHub Desktop.
Resize an image and constrain the image proportionately to a specified width, using ImageMagick (convert) from the command line.
#!/usr/bin/env bash
#
# The gist example here does not perform any sanity or error checking. It's just a gist.
#
# example: resize an image file to 150px width...
# ./convert.sh example.jpg 150
#
$FILENAME=$1
$WIDTH=$2
convert -geometry $WIDTH $FILENAME $FILENAME;
echo -e "\nDone!\n";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment