2016.06.30 12:23 "Re: [Tiff] Error messages regarding CFA tags: Unknown tags", by Even Rouault
Le jeudi 30 juin 2016 14:17:08, Fabian K a écrit:
Thank you very much for your prompt aswer! The problem remained when I applied your fix alone. Explicitly calling the static library for the compilation helped: g++ 16bit_raw.cpp -Wall -pedantic-errors \usr\local\lib\libtiff.a
That's probably just a matter of making sure you're linking at runtime against the right .so. Try LD_LIBRARY_PATH=/usr/local/lib
Currently, I'm trying to create a TIFF/EP Profile 2 .dng file from an arbitrary pixel array. I included all tags that I believe are necessary to have a complete file. However, there are three tags which are declared as mandatory in the TIFF/EP specification but don't seem to be implemented in libtiff: The SensingMethod, TIFF/EPStandardID and DateTimeOriginal tags. Do I really have to include them, and if so, how can I manually add them to libtiff? Last but not least, how can I calculate the value(s) for the mandatory StripOffset tag? I also have included tags that might or might not be necessary (I wasn't sure, the documentation is not always very precise), e.g. ColorMatrix1 tag.
If i try to convert my output file with dcraw, dcraw just displays that the file cannot be decoded. What am I doing wrong? Any help would be much appreciated. Please see my source code below.
Bests, Fabian
PS. Does someone have a TIFF/EP Profile 2 image and would like to send it to me? Then I could have a look into the header/tags and perhaps gain a better understanding of the file format...
TIFF *out = TIFFOpen("8bitRaw.dng", "w");
const int sampleperpixel = 1;
const int width = 4;
const int height = 4;unsigned char image[height][width*sampleperpixel] = {};
static const short bayerPatternDimensions[] = { 2,2 };
static const double cam_xyz[] = { 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0,
1.0, 1.0 };
static const double neutral[] = { 1.0, 1.0, 1.0 };//Arbitrary pixel intensities values:
image[0][0] = 4; image[0][1] = 14; image[0][2] = 150;
image[0][3] = 230;
image[1][0] = 141; image[1][1] = 24; image[1][2] = 0;
image[1][3] = 17;
image[2][0] = 255; image[2][1] = 27; image[2][2] = 120; image[2][3]
= 58;
image[3][0] = 25; image[3][1] = 2; image[3][2] = 42;
image[3][3] = 250;
TIFFSetField(out, TIFFTAG_SUBFILETYPE, 0);
TIFFSetField(out, TIFFTAG_IMAGEWIDTH, width);
TIFFSetField(out, TIFFTAG_IMAGELENGTH, height);
TIFFSetField(out, TIFFTAG_SAMPLESPERPIXEL, sampleperpixel);
TIFFSetField(out, TIFFTAG_ROWSPERSTRIP, TIFFDefaultStripSize(out, width*sampleperpixel));
TIFFSetField(out, TIFFTAG_BITSPERSAMPLE, 8);
TIFFSetField(out, TIFFTAG_XRESOLUTION, 75.0);
TIFFSetField(out, TIFFTAG_YRESOLUTION, 75.0);
TIFFSetField(out, TIFFTAG_RESOLUTIONUNIT, RESUNIT_INCH);TIFFSetField(out, TIFFTAG_ORIENTATION, ORIENTATION_TOPLEFT);
TIFFSetField(out, TIFFTAG_COMPRESSION, COMPRESSION_NONE);
TIFFSetField(out, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_CFA);
TIFFSetField(out, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG);
TIFFSetField(out, TIFFTAG_CFALAYOUT, 1);
TIFFSetField(out, TIFFTAG_CFAREPEATPATTERNDIM, bayerPatternDimensions);
TIFFSetField(out, TIFFTAG_CFAPATTERN, "\01\00\02\01");
TIFFSetField(out, TIFFTAG_MODEL, "TestModel");
TIFFSetField(out, TIFFTAG_MAKE, "TestMake");
TIFFSetField(out, TIFFTAG_SOFTWARE, "TestSoftware");
TIFFSetField(out, TIFFTAG_IMAGEDESCRIPTION, "TestImageDescription");
TIFFSetField(out, TIFFTAG_COPYRIGHT, "TestCopyright");
TIFFSetField(out, TIFFTAG_UNIQUECAMERAMODEL, "TestUniqueCameraModel");
TIFFSetField(out, TIFFTAG_DATETIME, "2016:06:30 11:11:15");
TIFFSetField(out, TIFFTAG_COLORMATRIX1, 9, cam_xyz);
TIFFSetField(out, TIFFTAG_ASSHOTNEUTRAL, 3, neutral);
TIFFSetField(out, TIFFTAG_CALIBRATIONILLUMINANT1, 21);
TIFFSetField(out, TIFFTAG_DNGVERSION, "\01\01\00\00");
TIFFSetField(out, TIFFTAG_DNGBACKWARDVERSION, "\01\00\00\00");//SensingMethodTag and TIFF/EPStandardID tag: Libtiff doesn't seem to
know these...
//TIFFSetField(out, 37399, 2);
//TIFFSetField(out, 37398, "\01\01\00\00");TIFFWriteScanline(out, image[0], 0, 0);
TIFFWriteScanline(out, image[1], 1, 0);TIFFWriteScanline(out, image[2], 2, 0);
TIFFWriteScanline(out, image[3], 3, 0);TIFFClose(out);
return 0;
}
--
Spatialys - Geospatial professional services
http://www.spatialys.com