TIFF and LibTiff Mail List Archive


2001.10.30 14:06 "Combining 2 tiff's", by William Kelleher
2001.11.04 20:02 "Re: Combining 2 tiff's", by Jon Saxton

2001.11.04 20:02 "Re: Combining 2 tiff's", by Jon Saxton

I need to combine 2 tiff images one is the front side of a check and the other is the back side. I want them front on top and back on bottom of the final image without changing the width or height of either image. I have looked at trying to use tiffcp from Libtiff but I am ether using the wrong parameters or it won't work.

I don't use libtiff so I can't tell you what calls to use but I can offer some overall suggestions. As I see it you have three options. Which works best for you depends on your exact requirements.

1. Join the two single-image TIFFs to make a 2-image TIFF. Each image is kept within its own IFD. Rely on your viewer to display the images the way you want. If you are writing the viewer, you can do this easily. The advantage of this technique is that you don't have to manipulate any TIFF structure below the IFD.

2. Treat the two images as strips of a single image and combine the two images into a single IFD in the order you want. Your viewer must know how to handle striped images. For this to work, you need to be sure that the images are the same width (in pixels) and that the first of the pair has at least as many rows as the second. Also look out for the orientation tag. If your data source is a cheque reader it may use orientation values other than 1. You'll need to manipulate a few tags in the IFD including the image height, strip offsets and strip byte counts. While this is a bit more complicated than the first option, you won't have to look inside the image data itself.

3. Combine the images. Extract and decompress each image, build a composite image from the two parts, re-compresss and wrap inside a single IFD in a new TIFF. Here you have to deal with much lower-level stuff but you have complete control and you are free of any limitations imposed by the other options.

That's all I have to offer. Maybe someone else has better ideas.

Jon Saxton <> OS/2 software developer
U.S. agent for Triton Technologies International Ltd