Created
July 22, 2010 13:05
-
-
Save chluehr/485932 to your computer and use it in GitHub Desktop.
BASH: resize/crop via ImageMagick
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# BASH: resize/crop via ImageMagick | |
#================================== | |
function resizecrop { | |
SIZE=$1 | |
SRC=$2 | |
DST_PATH=$3 | |
SRC_NAME=`basename $SRC` | |
# IM 6.3.8+ ONLY! (correct crop center) | |
#convert -size 300x300 $SRC \ | |
# -thumbnail ${SIZE}x${SIZE}^ \ | |
# -gravity center \ | |
# -extent ${SIZE}x${SIZE} \ | |
# $DST_PATH/$SRC_NAME | |
# old IM: pad with white ... | |
convert $SRC \ | |
-resize ${SIZE}x${SIZE}\> \ | |
-size ${SIZE}x${SIZE} xc:white +swap \ | |
-gravity center -composite \ | |
$DST_PATH/$SRC_NAME | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment