AWARE SYSTEMS
TIFF and LibTiff Mail List Archive

Thread

2012.02.22 08:22 "[Tiff] Creating a CMYK tiff", by dan claudiu zaharescu
2012.02.22 19:56 "Re: [Tiff] Creating a CMYK tiff", by Andreas Kleinert
2012.02.22 20:33 "Re: [Tiff] Creating a CMYK tiff", by Igor Skochinsky
2012.02.22 23:30 "Re: [Tiff] Creating a CMYK tiff", by Jürgen_Buchmüller
2012.02.23 02:02 "Re: [Tiff] Creating a CMYK tiff", by Bob Friesenhahn
2012.02.23 07:12 "Re: [Tiff] Creating a CMYK tiff", by dan claudiu zaharescu

2012.02.23 07:12 "Re: [Tiff] Creating a CMYK tiff", by dan claudiu zaharescu

Hello all,

Andreas,Igor, you are right,the problem was indeed at the viewers.

As it says in the TIFF documentation,

"Since separated images are quite device-specific and are restricted to color prepress use, they should not be used for general image data interchange. Separated images are to be used only for prepress applications in which the imagesetter, paper, ink, and printing press characteristics are known by the creator of the separated image.", a TIFF viewer is not forced by the specification to support this kind of files.

But for my purpose (to create a pdf file that contained this kind of tiff using pdflib), it worked.

I will put here my whole code that does the job (maybe it does not have the optimal structure yet, as I am in the prototyping phase, but it works)

I have colored in red the relevant calls.

static TIFF* initSeparatedImagesTiffParams(int pageNo,char *dataenc)
{
    std::string fullTiffFileName=data_path;
    char tiffFileName[256];
    sprintf(tiffFileName,"Page_%d_layer_%s_allLayers.tif",pageNo,dataenc);
    fullTiffFileName.append(tiffFileName);

    TIFF *image;
      // Open the TIFF file
    if((image = TIFFOpen(fullTiffFileName.c_str(), "w")) == NULL){
        printf("Could not open output.tif for writing\n");
        exit(42);
    }

TIFFSetField(image, TIFFTAG_SAMPLESPERPIXEL, 4);

  TIFFTAG_PLANARCONFIG, PLANARCONFIG_SEPARATE); TIFFSetField(image,

    TIFFSetField(image, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_SEPARATED);

    // Actually, I think these fields are corret, by default
    TIFFSetField(image, TIFFTAG_INKSET, INKSET_CMYK);
    TIFFSetField(image, TIFFTAG_NUMBEROFINKS, 4);

     // We need to set some values for basic tags before we can add any data

TIFFSetField(image, TIFFTAG_IMAGEWIDTH, width);

TIFFSetField(image, TIFFTAG_IMAGELENGTH, height);

    //4 parameters here are OK
    TIFFSetField(image, TIFFTAG_BITSPERSAMPLE, 8,8,8,8);

TIFFSetField(image, TIFFTAG_ROWSPERSTRIP, height);

    //This simply just puts LZW compression
    setCompression4(image,dataenc);

TIFFSetField(image, TIFFTAG_FILLORDER, FILLORDER_MSB2LSB);

TIFFSetField(image, TIFFTAG_XRESOLUTION, 600.0);

TIFFSetField(image, TIFFTAG_YRESOLUTION, 600.0);

TIFFSetField(image, TIFFTAG_RESOLUTIONUNIT, RESUNIT_INCH);

    return image;
}

static void writeStripsForAllLayers(TIFF *image,char *dataenc)
{
    if (strncmp(dataenc,"lzw",32)==0){
       // Write the information to the file
        TIFFWriteRawStrip(image, 0, buff, buffLen);
    }
    else {
        // Write the information to the file
        TIFFWriteEncodedStrip(image, 0, buff, buffLen);
    }
}

static void writeStripWithNumber(TIFF *image,char *dataenc,int strip_n)
{
    if (strncmp(dataenc,"lzw",32)==0){
       // Write the information to the file
        TIFFWriteRawStrip(image, strip_n, bufsSeparate[strip_n], bufsLens[strip_n]);
    }
    else {
        // Write the information to the file
        TIFFWriteEncodedStrip(image, 0, buff, buffLen);
    }
}

static void createTiffSeparatedImageSeparatedImages(int pageNo,char *dataenc)
{
    int nLayers=4;
    TIFF *image = initSeparatedImagesTiffParams(pageNo,dataenc);

    for (int i=0 ; i<4 ; i++) {
        getBuffFromFileForSeparateImages(pageNo,i,dataenc);
    }

   

    /*  This is how images are loaded, one