Tiff tiles on original position on jpg canvas
Posted: 2012-10-07T11:21:31-07:00
I have to create a tiling solution for incoming tiff files and the format of output tiles has to be jpg. Each tile has to be in separate file and located on a black canvas (same size as incoming tiff) on the same position as in the original tiff file. I found the following script that solves somewhat my problem but it is slow when incoming tiffs are large (~100MB) and therefore I'm looking for a better solution.
Code: Select all
src=$1
width=`identify -format %w $src`
limit=$[$width / 256]
echo "count = $limit * $limit = "$((limit * limit))" tiles"
limit=$((limit-1))
convert $src -alpha transparent -alpha extract canvas.png
for x in `seq 0 $limit`; do
for y in `seq 0 $limit`; do
tile=tile-$x-$y.png
echo -n $tile
w=$((x * 256))
h=$((y * 256))
convert -debug cache -monitor $src -crop 256x256+$w+$h $tile
convert -page +w+h canvas.png $tile -flatten $x-$y.jpg
done
done