#!/bin/sh

SRC='P1020267.JPG P1020269.JPG P1020270.JPG P1020271.JPG P1020272.JPG
     P1020274.JPG P1020278.JPG P1020280.JPG P1020282.JPG P1020285.JPG
     P1020288.JPG P1020291.JPG P1020295.JPG P1020296.JPG P1020297.JPG'
DST='bat-2007'

mkdir -p ../../tmp/www/${DST}/small ../../tmp/www/${DST}/big

N=0
for n in ${SRC}
do
    o=$(printf '%s-%04d.jpeg' ${DST} ${N})
    N=$((${N}+1))
    echo "${n} => ${o}"
    #(
        cp ${n} ${o}
        exifautotran ${o}
        convert ${o} \
            -strip \
            -gamma 1,1.1,1.05 \
            -unsharp 0x0.3 \
            -resize x1536 -unsharp 0x0.75+0.6+0.04 \
            -quality 90 +write ../../tmp/www/${DST}/big/${o} \
            -resize x768 -unsharp 0x0.75+0.6+0.04 -quality 90 \
            +write ../../tmp/www/${DST}/${o} \
            -resize x384 -unsharp 0x0.65+0.6+0.03 \
            -resize x256 -unsharp 0x0.65+0.6+0.03 \
            -quality 90 ../../tmp/www/${DST}/small/${o}
        rm ${o}
    #) &
    [ $((${N}%4)) -ne 0 ] || wait 
done
