AWARE SYSTEMS
TIFF and LibTiff Mail List Archive

Thread

2005.01.20 20:08 "[Tiff] deleting tags!", by Antoine
2005.01.21 15:14 "Re: [Tiff] deleting tags!", by Frank Warmerdam
2005.01.21 15:20 "Re: [Tiff] deleting tags!", by Chris Losinger
2005.01.21 17:42 "Re: [Tiff] deleting tags!", by Frank Warmerdam
2005.01.21 18:29 "Re: [Tiff] deleting tags!", by Antoine
2005.01.21 20:02 "Re: [Tiff] deleting tags!", by Frank Warmerdam
2005.01.21 20:27 "Re: [Tiff] deleting tags!", by Antoine
2005.01.21 21:49 "Re: [Tiff] deleting tags!", by Andrey Kiselev
2005.01.21 22:47 "[Tiff] removing tiff header tags", by Antoine
2005.01.22 05:40 "Re: [Tiff] removing tiff header tags", by Frank Warmerdam

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 ;-).

Antoine,

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

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_BITSPERSAMPLE, &bpp);
    TIFFGetField(tif, TIFFTAG_SAMPLESPERPIXEL, &spp);
    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_BITSPERSAMPLE, bpp);
    TIFFSetField(out, TIFFTAG_SAMPLESPERPIXEL, spp);
    TIFFSetField(out, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG);
    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);

    _TIFFfree(buf);
    TIFFClose(out);
    TIFFClose(tif);

    return 0;
}