Received: from lists.maptools.org (ks365428.kimsufi.com [94.23.4.142])
	by smtp.simplesystems.org (8.14.4+Sun/8.14.4) with ESMTP id u5UCLG40008384
	for <bfriesen@simple.dallas.tx.us>; Thu, 30 Jun 2016 07:21:16 -0500 (CDT)
Received: from [10.1.0.241] (localhost.localdomain [127.0.0.1])
	by lists.maptools.org (Postfix) with ESMTP id 0945F35C055;
	Thu, 30 Jun 2016 07:21:12 -0500 (EST)
Received: from mail-wm0-f49.google.com (mail-wm0-f49.google.com [74.125.82.49])
	by lists.maptools.org (Postfix) with ESMTPS id B0B8B35C055
	for <tiff@lists.maptools.org>; Thu, 30 Jun 2016 07:17:09 -0500 (EST)
Received: by mail-wm0-f49.google.com with SMTP id r190so4020171wmr.0
	for <tiff@lists.maptools.org>; Thu, 30 Jun 2016 05:17:09 -0700 (PDT)
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
	d=1e100.net; s=20130820;
	h=x-gm-message-state:mime-version:in-reply-to:references:from:date
	:message-id:subject:to:cc;
	bh=QK5uFKCymVt3DzisK1vUElkFXrrmw6WE5tPP5Af6seg=;
	b=XO6KWQMk8NRhspZro+WwrPngvAx2KYaExjT/ILSG6lQbQe25hgJE4BcLnKTnRwWex8
	arqb/8XjKWZJyI9l/zj2cfEFG00CTL9COAkMmQpdoPzWkh2ej62xTHBKAILmy4GhjXGx
	EHbZyf6KUGEMwFfeuG1Rr10LldMI4wHaiE7Afg5owoMWGlqkXdMflI2QFSy3BhCFPe8/
	Xik7rYDwJ0t8+8qBKGmyXbzgNCQsASWqEx1Fh+fu75mf2+SLrNXbHuzrcAE2FnBGckZr
	MQeWB+WaxQE5S1gD1w/JN3HMXUXvwhZjs868CPtir1nKFNGMPFzPPFvounUfmGzTXW/7
	3wXw==
X-Gm-Message-State: ALyK8tJO8MFfkkTl/172XJiXQcRI58UQekGAntL3BqV9P6/blPRd0BbVc4QRcCDHju/mJ0FC7nNWeBwhDjr2fQ==
X-Received: by 10.194.109.199 with SMTP id hu7mr13432943wjb.6.1467289028784;
	Thu, 30 Jun 2016 05:17:08 -0700 (PDT)
MIME-Version: 1.0
Received: by 10.194.140.73 with HTTP; Thu, 30 Jun 2016 05:17:08 -0700 (PDT)
In-Reply-To: <201606282212.41471.even.rouault@spatialys.com>
References: <CAOnfLPWFdYFFtr_KuwYcb6UNivdxCtKCY=cOSy6-gFq0SLKKEA@mail.gmail.com>
	<201606282212.41471.even.rouault@spatialys.com>
From: Fabian K <fabian.k12@gmail.com>
Date: Thu, 30 Jun 2016 14:17:08 +0200
Message-ID: <CAOnfLPW-8CJKyzmz+1iE_9nQ6p5t-eTc_iTodpUQjtS58pquCQ@mail.gmail.com>
To: Even Rouault <even.rouault@spatialys.com>
Cc: tiff@lists.maptools.org
Subject: Re: [Tiff] Error messages regarding CFA tags: Unknown tags
X-BeenThere: tiff@lists.maptools.org
X-Mailman-Version: 2.1.9
Precedence: list
List-Id: TIFF and libtiff discussion <tiff.lists.maptools.org>
List-Unsubscribe: <http://lists.maptools.org/mailman/listinfo/tiff>,
	<mailto:tiff-request@lists.maptools.org?subject=unsubscribe>
List-Archive: <http://lists.maptools.org/mailman/private/tiff>
List-Post: <mailto:tiff@lists.maptools.org>
List-Help: <mailto:tiff-request@lists.maptools.org?subject=help>
List-Subscribe: <http://lists.maptools.org/mailman/listinfo/tiff>,
	<mailto:tiff-request@lists.maptools.org?subject=subscribe>
Content-Type: multipart/mixed; boundary="===============1136202805=="
Mime-version: 1.0
Sender: tiff-bounces@lists.maptools.org
Errors-To: tiff-bounces@lists.maptools.org
X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (smtp.simplesystems.org [65.66.246.90]); Thu, 30 Jun 2016 07:21:16 -0500 (CDT)
X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4
Status: RO
X-Status: 
X-Keywords:                 
X-UID: 39

--===============1136202805==
Content-Type: multipart/alternative; boundary=047d7bf10a4e57f5ad05367dd9ca

--047d7bf10a4e57f5ad05367dd9ca
Content-Type: text/plain; charset=UTF-8

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

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


#include "tiffio.h"
#include <iostream>
using namespace std;

int main(void)
{
    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;
}

--047d7bf10a4e57f5ad05367dd9ca
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div><div><div><div>Thank you very much for your prompt as=
wer! The problem remained when I applied your fix alone. Explicitly calling=
 the static library for the compilation helped: g++ 16bit_raw.cpp -Wall -pe=
dantic-errors \usr\local\lib\libtiff.a<br><br></div>Currently, I&#39;m tryi=
ng 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. Ho=
wever, there are three tags which are declared as mandatory in the TIFF/EP =
specification but don&#39;t seem to be implemented in libtiff: The SensingM=
ethod, TIFF/EPStandardID and DateTimeOriginal tags. Do I really have to inc=
lude 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&#39;=
t sure, the documentation is not always very precise), e.g. ColorMatrix1 ta=
g.<br></div><div><br></div> 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.<br><b=
r></div>Bests, Fabian<br><br></div>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...<b=
r><div><br><br>#include &quot;tiffio.h&quot;<br>#include &lt;iostream&gt;<b=
r>using namespace std;<br><br>int main(void)<br>{<br>=C2=A0=C2=A0=C2=A0 TIF=
F *out =3D TIFFOpen(&quot;8bitRaw.dng&quot;, &quot;w&quot;);<br><br>=C2=A0=
=C2=A0=C2=A0 const int sampleperpixel =3D 1;<br>=C2=A0=C2=A0=C2=A0 const in=
t width =3D 4;<br>=C2=A0=C2=A0=C2=A0 const int height =3D 4;<br><br>=C2=A0=
=C2=A0=C2=A0 unsigned char image[height][width*sampleperpixel] =3D {};<br>=
=C2=A0=C2=A0=C2=A0 static const short bayerPatternDimensions[] =3D { 2,2 };=
<br>=C2=A0=C2=A0=C2=A0 static const double cam_xyz[] =3D { 1.0, 1.0, 1.0, 1=
.0, 1.0, 1.0, 1.0, 1.0, 1.0 };<br>=C2=A0=C2=A0=C2=A0 static const double ne=
utral[] =3D { 1.0, 1.0, 1.0 };<br>=C2=A0=C2=A0=C2=A0 <br>=C2=A0=C2=A0=C2=A0=
 //Arbitrary pixel intensities values:<br>=C2=A0=C2=A0=C2=A0 image[0][0] =
=3D 4;=C2=A0 =C2=A0=C2=A0 image[0][1] =3D 14;=C2=A0=C2=A0 image[0][2] =3D 1=
50;=C2=A0 image[0][3] =3D 230;<br>=C2=A0=C2=A0=C2=A0 image[1][0] =3D 141;=
=C2=A0 image[1][1] =3D 24;=C2=A0=C2=A0 image[1][2] =3D 0; =C2=A0 =C2=A0 ima=
ge[1][3] =3D 17;<br>=C2=A0=C2=A0=C2=A0 image[2][0] =3D 255;=C2=A0 image[2][=
1] =3D 27;=C2=A0=C2=A0 image[2][2] =3D 120;=C2=A0 image[2][3] =3D 58;<br>=
=C2=A0=C2=A0=C2=A0 image[3][0] =3D 25; =C2=A0=C2=A0 image[3][1] =3D 2; =C2=
=A0 =C2=A0 image[3][2] =3D 42;=C2=A0=C2=A0 image[3][3] =3D 250;<br><br>=C2=
=A0=C2=A0=C2=A0 TIFFSetField(out, TIFFTAG_SUBFILETYPE, 0);<br>=C2=A0=C2=A0=
=C2=A0 TIFFSetField(out, TIFFTAG_IMAGEWIDTH, width);<br>=C2=A0=C2=A0=C2=A0 =
TIFFSetField(out, TIFFTAG_IMAGELENGTH, height);<br>=C2=A0=C2=A0=C2=A0 TIFFS=
etField(out, TIFFTAG_SAMPLESPERPIXEL, sampleperpixel);<br>=C2=A0=C2=A0=C2=
=A0 TIFFSetField(out, TIFFTAG_ROWSPERSTRIP, TIFFDefaultStripSize(out, width=
*sampleperpixel));<br>=C2=A0=C2=A0=C2=A0 TIFFSetField(out, TIFFTAG_BITSPERS=
AMPLE, 8);<br>=C2=A0=C2=A0=C2=A0 TIFFSetField(out, TIFFTAG_XRESOLUTION, 75.=
0);<br>=C2=A0=C2=A0=C2=A0 TIFFSetField(out, TIFFTAG_YRESOLUTION, 75.0);<br>=
=C2=A0=C2=A0=C2=A0 TIFFSetField(out, TIFFTAG_RESOLUTIONUNIT, RESUNIT_INCH);=
<br>=C2=A0=C2=A0=C2=A0 TIFFSetField(out, TIFFTAG_ORIENTATION, ORIENTATION_T=
OPLEFT);<br>=C2=A0=C2=A0=C2=A0 TIFFSetField(out, TIFFTAG_COMPRESSION, COMPR=
ESSION_NONE);<br>=C2=A0=C2=A0=C2=A0 TIFFSetField(out, TIFFTAG_PHOTOMETRIC, =
PHOTOMETRIC_CFA);<br>=C2=A0=C2=A0=C2=A0 TIFFSetField(out, TIFFTAG_PLANARCON=
FIG, PLANARCONFIG_CONTIG);<br>=C2=A0=C2=A0=C2=A0 TIFFSetField(out, TIFFTAG_=
CFALAYOUT, 1);<br>=C2=A0=C2=A0=C2=A0 TIFFSetField(out, TIFFTAG_CFAREPEATPAT=
TERNDIM, bayerPatternDimensions);<br>=C2=A0=C2=A0=C2=A0 TIFFSetField(out, T=
IFFTAG_CFAPATTERN, &quot;\01\00\02\01&quot;);<br>=C2=A0=C2=A0=C2=A0 <br>=C2=
=A0=C2=A0=C2=A0 TIFFSetField(out, TIFFTAG_MODEL, &quot;TestModel&quot;);<br=
>=C2=A0=C2=A0=C2=A0 TIFFSetField(out, TIFFTAG_MAKE, &quot;TestMake&quot;);<=
br>=C2=A0=C2=A0=C2=A0 TIFFSetField(out, TIFFTAG_SOFTWARE, &quot;TestSoftwar=
e&quot;);<br>=C2=A0=C2=A0=C2=A0 TIFFSetField(out, TIFFTAG_IMAGEDESCRIPTION,=
 &quot;TestImageDescription&quot;);<br>=C2=A0=C2=A0=C2=A0 TIFFSetField(out,=
 TIFFTAG_COPYRIGHT, &quot;TestCopyright&quot;);<br>=C2=A0=C2=A0=C2=A0 TIFFS=
etField(out, TIFFTAG_UNIQUECAMERAMODEL, &quot;TestUniqueCameraModel&quot;);=
<br>=C2=A0=C2=A0=C2=A0 TIFFSetField(out, TIFFTAG_DATETIME, &quot;2016:06:30=
 11:11:15&quot;);<br>=C2=A0=C2=A0=C2=A0 TIFFSetField(out, TIFFTAG_COLORMATR=
IX1, 9, cam_xyz);<br>=C2=A0=C2=A0=C2=A0 TIFFSetField(out, TIFFTAG_ASSHOTNEU=
TRAL, 3, neutral);<br>=C2=A0=C2=A0=C2=A0 TIFFSetField(out, TIFFTAG_CALIBRAT=
IONILLUMINANT1, 21);<br>=C2=A0=C2=A0=C2=A0 TIFFSetField(out, TIFFTAG_DNGVER=
SION, &quot;\01\01\00\00&quot;);<br>=C2=A0=C2=A0=C2=A0 TIFFSetField(out, TI=
FFTAG_DNGBACKWARDVERSION, &quot;\01\00\00\00&quot;);<br>=C2=A0=C2=A0=C2=A0 =
//SensingMethodTag and TIFF/EPStandardID tag: Libtiff doesn&#39;t seem to k=
now these...<br>=C2=A0=C2=A0=C2=A0 //TIFFSetField(out, 37399, 2);<br>=C2=A0=
=C2=A0=C2=A0 //TIFFSetField(out, 37398, &quot;\01\01\00\00&quot;);<br>=C2=
=A0=C2=A0=C2=A0 <br>=C2=A0=C2=A0=C2=A0 TIFFWriteScanline(out, image[0], 0, =
0);<br>=C2=A0=C2=A0=C2=A0 TIFFWriteScanline(out, image[1], 1, 0);<br>=C2=A0=
=C2=A0=C2=A0 TIFFWriteScanline(out, image[2], 2, 0);<br>=C2=A0=C2=A0=C2=A0 =
TIFFWriteScanline(out, image[3], 3, 0);<br>=C2=A0=C2=A0=C2=A0 TIFFClose(out=
);<br><br>=C2=A0=C2=A0=C2=A0 return 0;<br>}<br><div><div><div><div><div><di=
v><br><br></div></div></div></div></div></div></div></div>

--047d7bf10a4e57f5ad05367dd9ca--

--===============1136202805==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
Tiff mailing list: Tiff@lists.maptools.org
http://lists.maptools.org/mailman/listinfo/tiff
http://www.remotesensing.org/libtiff/
--===============1136202805==--

