#!/bin/tcsh

foreach f (/san/sanvol1/scratch/visiGene/jpgTest/Zz*.jp2)
   
    echo "processing $f ..."
    
    set origf=$f
    set f="Z-test4.jpg"
    
    set filename=$f:t
    set basename=$f:r
    set ext="jpg"

    mkdir $basename
    cd $basename
    set filepath="../${basename}.${ext}"
    jp2ToJpg $origf $filepath

    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

