Resizing and rotating images before upload

Jurjen Bokma

April 2010


I move all the rotated images to a directory 'rot', then rotate them all back with:

for i in $(ls -1 *.jpg) ; do
    convert -rotate 270 $i ${i}.rotated \
    && rm $i \
    && mv ${i}.rotated $i
done

... and then I copy them back into the main directory and resize them with:

time \
for i in $(ls -1 *.jpg) ; do
    if identify $i |grep -q 2048 ; then
        convert -resize 50% $i $i.resized \
        && rm $i \
        && mv $i.resized $i
    fi
done

After that, only igal and rsync remain.