2003.12.19 07:14 "[Tiff] Reading and writing out TIFFTAG_CLIPPATH", by Jae Ho Lee

2003.12.26 11:37 "Re: [Tiff] Reading and writing out TIFFTAG_CLIPPATH", by Andrey Kiselev

Hello,

But I still could not write PHOTOSHOP tag data to newly created tiff image until I made below changes to TIFFWriteNormalTag() fuction in tif_dirwrite.c file.

I can't reproduce your problem with the file you sent to me. Attached sample program works well and Photoshop tag is properly copied to the output image.

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

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

int main (int argc, char **argv)
{
    unsigned int i, count;
    TIFF *in, *out;
    uint16 spp, bpp, photo;
    uint32 image_width, image_height;
    char *buf, *photoshop;

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

    TIFFGetField(in, TIFFTAG_IMAGELENGTH, &image_height);
    TIFFGetField(in, TIFFTAG_BITSPERSAMPLE, &bpp);
    TIFFGetField(in, TIFFTAG_SAMPLESPERPIXEL, &spp);
    TIFFGetField(in, TIFFTAG_PHOTOMETRIC, &photo);

    TIFFGetField(in, TIFFTAG_PHOTOSHOP, &count, &photoshop);
    fprintf(stdout, "Photoshop tag length: %d\n", count);

    image_width = TIFFScanlineSize(in);
    buf = malloc(image_width * image_height);
    for (i = 0; i < image_height; i++)
        TIFFReadScanline(in, &buf[i * image_width], i, 0);

    out = TIFFOpen("out.in", "w");
    TIFFSetField(out, TIFFTAG_IMAGEWIDTH, image_width / spp);
    TIFFSetField(out, TIFFTAG_BITSPERSAMPLE, bpp);
    TIFFSetField(out, TIFFTAG_SAMPLESPERPIXEL, spp);
    TIFFSetField(out, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG);
    TIFFSetField(out, TIFFTAG_PHOTOMETRIC, photo);
    TIFFSetField(out, TIFFTAG_PHOTOSHOP, count, photoshop);
    TIFFSetField(out, TIFFTAG_ROWSPERSTRIP, TIFFDefaultStripSize(out, 0));
    for (i = 0; i < image_height; i++)
        TIFFWriteScanline(out, &buf[i * image_width], i, 0);

    TIFFClose(out);
    TIFFClose(in);

    return 0;
}