2005.01.20 20:08 "[Tiff] deleting tags!", by Antoine

2005.01.21 21:49 "Re: [Tiff] deleting tags!", by Andrey Kiselev

I guess I'll have a look and see what I can understand in tiffcp. In fact, for what we wanted to do getting rid of the unknown tags was a feature! There were some tags photoshop put in that are also not in the ATA spec, so they had to go - tiffcp not copying them was great. I guess at the very least it will be a good base to work from. I warn you, you may get some silly questions though. I will try my best ;-).


If the input files are all in the same simple format you can easily write a tool to convert them in the form you need. Attached code should help you to understand the basic idea how to do that.


Andrey V. Kiselev
Home phone: +7 812 5970603 ICQ# 26871517

#include <stdio.h>
#include <stdlib.h>
#include "tiffio.h"

int main (int argc, char **argv)
    unsigned int i;
    TIFF *tif, *out;
    uint16 spp, bpp, photo;
    uint32 image_width, image_height, scansize;
    char *buf;

    if(argc < 3)
        fprintf(stderr, "\nUSAGE: tiffcopy infile.tif outfile.tif\n");
        return 1;

    tif = TIFFOpen(argv[1], "r");
    if (!tif)
        fprintf (stderr, "Can't open %s for reading\n", argv[1]);
        return 2;

    out = TIFFOpen(argv[2], "w");
    if (!out)
        fprintf (stderr, "Can't open %s for writing\n", argv[2]);
        return 3;

    TIFFGetField(tif, TIFFTAG_IMAGEWIDTH, &image_width);
    TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &image_height);
    TIFFGetField(tif, TIFFTAG_PHOTOMETRIC, &photo);
    scansize = TIFFScanlineSize(tif);
    buf = _TIFFmalloc(scansize * image_height);
    for (i = 0; i < image_height; i++)
        TIFFReadScanline(tif, buf + i * scansize, i, 0);

    TIFFSetField(out, TIFFTAG_IMAGEWIDTH, image_width);
    TIFFSetField(out, TIFFTAG_IMAGELENGTH, image_height);
    TIFFSetField(out, TIFFTAG_PHOTOMETRIC, photo);
    TIFFSetField(out, TIFFTAG_ROWSPERSTRIP, TIFFDefaultStripSize(out, 0));
    for (i = 0; i < image_height; i++)
        TIFFWriteScanline(out, buf + i * scansize, i, 0);


    return 0;