#!/bin/tcsh

foreach f (*.jpg)
   
    echo "processing $f ..."
    mkdir $f:r
    cd $f:r

    set filepath="../$f"

    set filename=$filepath:t
    set basename=$filename:r
    set ext=$filename:e

    convert $filepath               -crop 512x512 -quality 75 ${basename}_0_%03d.$ext
    convert $filepath -resize 50%   -crop 512x512 -quality 75 ${basename}_1_%03d.$ext
    convert $filepath -resize 25%   -crop 512x512 -quality 75 ${basename}_2_%03d.$ext
    convert $filepath -resize 12.5% -crop 512x512 -quality 75 ${basename}_3_%03d.$ext
    convert $filepath -resize 6.25% -crop 512x512 -quality 75 ${basename}_4_%03d.$ext

    cd ..
    
end

