Convert large Tiff image to smaller tiles

You have received some drawings in a Tiff file format. The resolution is 200 dpi and some drawings can be 36″ wide by 100″ long. Your requirement is to create 11X17″ tiles of these drawings. Your desire is to maintain resolution, automated tiles and make sure the tiles are logical,so that one tile does not have information on another tile.


The following shell script will take one parameter: The filename of a 200 dpi tiff file.

#!/bin/sh

infile=$1

# Sizes are metric sizes (in inches) multiplied by resolution (in dpi)
dpi=200
xtilesize=2200
ytilesize=3400

# With a 0.5 inch margin on all sides the values would be
# xtilesize=2000
# ytilesize=3200

xdim=`ecconv -info $infile | grep Dimension | awk ‘{print $3}’`
ydim=`ecconv -info $infile | grep Dimension | awk ‘{print $5}’`

ytile=0
yoff=0
while [ $yoff -lt $ydim ]; do
    xtile=0
    xoff=0
    while [ $xoff -lt $xdim ]; do
        ecconv -exp tif -crop ${xtilesize}x$ytilesize+$xoff+$yoff $infile $infile.x$xtile-y$ytile
        xoff=`expr $xoff + 2200`
        xtile=`expr $xtile + 1`
    done
    yoff=`expr $yoff + 3400`
    ytile=`expr $ytile + 1`
done


It will then create a bunch of tiff files with names <fn>.x <n>y <m> that are tiles of the original tiff. All the tiles will be 200 dpi, and they will be 11×17″ except for the rightmost tiles, which will probably be narrower and the bottommost tiles, which will probably be shorter. The script produces as many tiles as necessary for the given input file.

If the basic functionality of the script is what you ask for, we could refine the script on such topics as desired compression method and desired output filenames.

It will then create a bunch of tiff files with names <fn>.x <n>y <m> that are tiles of the original tiff. All the tiles will be 200 dpi, and they will be 11×17″ except for the rightmost tiles, which will probably be narrower and the bottommost tiles, which will probably be shorter. The script produces as many tiles as necessary for the given input file.

If the basic functionality of the script is what you ask for, it is a small task to refine the script on such topics as desired compression method and desired output filenames.