#!/bin/sh

NONA='nona -t 2'
CCM='color_correct -E -c -p.03 -D64 -a -8192:8192+1024 -k 24:40/32 -g 24:40/32 -o tmp.tiff'
ENBL='enblend -w -z -m 768 -f 12726x4285'
CONV='convert -limit memory 512 -limit map 256'

${NONA} -o tmp+1- home-5+1.pto
${CCM} tmp+1-0003.tif tmp+1-0004.tif && mv tmp.tiff tmp+1-0004.tif
${CCM} tmp+1-0004.tif tmp+1-0005.tif && mv tmp.tiff tmp+1-0005.tif
${CCM} tmp+1-0005.tif tmp+1-0006.tif && mv tmp.tiff tmp+1-0006.tif
${CCM} tmp+1-0003.tif tmp+1-0002.tif && mv tmp.tiff tmp+1-0002.tif
${CCM} tmp+1-0002.tif tmp+1-0001.tif && mv tmp.tiff tmp+1-0001.tif
${CCM} tmp+1-0001.tif tmp+1-0000.tif && mv tmp.tiff tmp+1-0000.tif
${ENBL} -o tmp+1.tiff tmp+1-0*.tif
rm -f tmp+1-0*.tif

${NONA} -o tmp+0- home-5+0.pto
${CCM} tmp+0-0003.tif tmp+0-0004.tif && mv tmp.tiff tmp+0-0004.tif
${CCM} tmp+0-0004.tif tmp+0-0005.tif && mv tmp.tiff tmp+0-0005.tif
${CCM} tmp+0-0005.tif tmp+0-0006.tif && mv tmp.tiff tmp+0-0006.tif
${CCM} tmp+0-0003.tif tmp+0-0002.tif && mv tmp.tiff tmp+0-0002.tif
${CCM} tmp+0-0002.tif tmp+0-0001.tif && mv tmp.tiff tmp+0-0001.tif
${CCM} tmp+0-0001.tif tmp+0-0000.tif && mv tmp.tiff tmp+0-0000.tif
${ENBL} -o tmp+0.tiff tmp+0-0*.tif
rm -f tmp+0-0*.tif

${NONA} -o tmp-1- home-5-1.pto
${CCM} tmp-1-0003.tif tmp-1-0004.tif && mv tmp.tiff tmp-1-0004.tif
${CCM} tmp-1-0004.tif tmp-1-0005.tif && mv tmp.tiff tmp-1-0005.tif
${CCM} tmp-1-0005.tif tmp-1-0006.tif && mv tmp.tiff tmp-1-0006.tif
${CCM} tmp-1-0003.tif tmp-1-0002.tif && mv tmp.tiff tmp-1-0002.tif
${CCM} tmp-1-0002.tif tmp-1-0001.tif && mv tmp.tiff tmp-1-0001.tif
${CCM} tmp-1-0001.tif tmp-1-0000.tif && mv tmp.tiff tmp-1-0000.tif
${ENBL} -o tmp-1.tiff tmp-1-0*.tif
rm -f tmp-1-0*.tif

${NONA} -o hdr- home-5-hdr.pto
rm -f tmp[+-][0-9].tiff

${CONV} hdr-0000.tif -crop 11904x2816+192+560 +repage -adaptive-sharpen 4x1 -filter triangle -support 1.1 -resize x2048 -compress LZW hdr+0.tiff
${CONV} hdr-0001.tif -crop 11904x2816+192+560 +repage -adaptive-sharpen 4x1 -filter triangle -support 1.1 -resize x2048 -compress LZW hdr+1.tiff
${CONV} hdr-0002.tif -crop 11904x2816+192+560 +repage -adaptive-sharpen 4x1 -filter triangle -support 1.1 -resize x2048 -compress LZW hdr-1.tiff
rm -f hdr-00*.tif
