2006.01.10 17:40 "[Tiff] Adding a blank heading to a tiff using C/C++", by John Kearns

2006.01.10 22:29 "RE: [Tiff] Adding a blank heading to a tiff using C/C++", by

JK> How can I add a banner to all of the pages of a multipage

tiff (both stripped and tiled) using C or C++? Merely, stretching the length will not do, we need to append a blank heading on the top and then write our (dynamic) banner there.

Tiled starts to get complicated, as far as I understand it. You might want to go for a more caveman-tastic approach if you don't have time to spare for crafting a good, versatile, robust solution (to me, it's non-trivial, anyway). Here's how you might do it:

  1. Write a simple app that uses scanline-based IO. Read the basic info from the original file (colour depth, etc), and then create a new (target) file, first placing your banner data there (in the format matching the original image, like RGBA or whatnot -- see TIFFWriteScanline), and then read the original image data line by line (see TIFFReadScanline) and append it to the target file after the banner data. See this page for some hints: http://www.libtiff.org/libtiff.html (section titled "Scanline-based Image I/O"). And a slight improvement is probably reading the original data raw (TIFFReadRawStrip), and writing it to the target raw (you guessed it, TIFFWriteRawstrip), to save the bother of decompressing only to recompress. I don't know if there would be complications because your original strip is "shorter" than your final height. Anyway...
  2. Using the magic of batch files, and the existing tiff tools, split each multi-page image into separate single-page TIFFs (tiffsplit), and at the same time, convert to single-strip, non-tiled. Then your simple app adds the banner to each "page". Then glue the "pages" back together into one multi-page TIFF (tiffcp), converting back to multi-strip/tiled/whatever at the same time.
  3. It's so crazy, it just might work. (Please send flames directly to me, so as not to clog the list). :-)

Good luck!