Image Magick bash script to resize and crop images

Resizing images is often something that any web developer has to do.movie Hacksaw Ridge 2016 trailer

This is a bash script which resizes and crops images to a perfect 72×72 square.

#!/bin/sh

# script to resize and crop

dir="/Users/data/files/candidate/photo/"
resume=resume
orig=_orig
cd "$dir$orig"
for k in `ls * cialis von lilly.jpg`
do	
	h=`identify -format "%h" $k`
	w=`identify -format "%w" $k`
	#echo "$k, w:$w, h:$h"
	#If landscape
	if [ $w -ge $h ]
		then
	   	 convert $k -resize x72 -crop 72x72+0+0  "$dir$resume/$k"
	     #echo "landscape"
		else
		 convert $k -resize 72x -crop 72x72+0+0 "$dir$resume/$k"
	     #echo "portrait"
	fi
	
done

Comments are closed.