Skip to content

Instantly share code, notes, and snippets.

@chluehr
Created January 26, 2011 14:43
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chluehr/796772 to your computer and use it in GitHub Desktop.
Save chluehr/796772 to your computer and use it in GitHub Desktop.
Shell Script to resize / crop images via ImageMagick (min. V6.3.8)
#!/bin/bash
#==========================================
# source size is 300x300 ..
function resizecrop {
SIZE=$1
SRCFILE=$2
DESTFILE=$3
convert -size 300x300 $SRCFILE \
-thumbnail ${SIZE}x${SIZE}^ \
-gravity center \
-extent ${SIZE}x${SIZE} \
$DESTFILE
}
for i in *.jpg
do
resizecrop 100 "$i" `basename $1 .jpg`_100x100.jpg
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment