Return-Path: <SRS0=7Tmh=AD=lists.osgeo.org=tiff-bounces@osgeo.org>
Delivered-To: filtered@awaresystems.be
Received: from mx3.pub.mailpod8-cph3.one.com ([10.27.38.13])
	by mailstorage22.cst.mailpod8-cph3.one.com with LMTP
	id QIiqAIUTN2SLRQAAwT5NuQ
	(envelope-from <SRS0=7Tmh=AD=lists.osgeo.org=tiff-bounces@osgeo.org>)
	for <filtered@awaresystems.be>; Wed, 12 Apr 2023 20:24:37 +0000
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
	d=custmx.one.com; s=20201015;
	h=sender:content-type:list-subscribe:list-help:list-post:list-unsubscribe:
	 list-id:subject:mime-version:message-id:date:in-reply-to:references:cc:to:from:
	 x-halone-refid:x-halone-sa:from:x-halone-sa:x-halone-refid;
	bh=7etMy3XR2fjnrSZIQeYl4rfUpASdFPpmKnTtv1MFnhI=;
	b=EYVd6pnrkz1XVRFKnkjipUPLrX0ejsb2rkbna7RGqL4mVMA8Jfdg0o4ROWT8uwixUwmOAoe5w2B7i
	 X4al/iGojfK6Rro3nzZenkrExEXSSgvN5H/FoFzNBDuQme3igPL2Tpqp0YGaV9tBclv4vaBC76ua01
	 ntQHp4iVdIgqYMeZag3YiEQMFYuQbS+ufcnciB7MldnI8rx4lu388ZScRg1NXaSprTyJyTknV1nwOH
	 0qXH78NJ/6y8mT5bB8AGIex5ENhMunPTRiOMiWEFjRdMogv5CZVUVfL3NFPkQrvvzeCwadGLHEaCaJ
	 oR5Cur8g8204veOe0rsKeDGwSjd38hg==
X-HalOne-SA: -0.7
X-HalOne-RefID: 155866::1681331075-85F3D120-9DA88395/0/0
X-HalOne-ID: 09935027-d970-11ed-9491-98039b062cb2
Received: from lists.osgeo.org (osgeo6.osgeo.osuosl.org [140.211.15.3])
	by mx3.pub.mailpod8-cph3.one.com (Halon) with ESMTPS
	id 09935027-d970-11ed-9491-98039b062cb2;
	Wed, 12 Apr 2023 20:24:35 +0000 (UTC)
Received: from osgeo6.osgeo.osuosl.org (localhost [127.0.0.1])
	by lists.osgeo.org (Postfix) with ESMTP id E89B06126C36;
	Wed, 12 Apr 2023 13:24:30 -0700 (PDT)
Received: from avasout-peh-002.plus.net (avasout-peh-002.plus.net
 [212.159.14.18])
 by lists.osgeo.org (Postfix) with ESMTPS id C9DA161346CD
 for <tiff@lists.osgeo.org>; Wed, 12 Apr 2023 13:24:28 -0700 (PDT)
Received: from Apollo ([212.159.61.44]) by smtp with ESMTPA
 id mh0ypzCVDFjSAmh10puB7A; Wed, 12 Apr 2023 21:24:26 +0100
X-Clacks-Overhead: "GNU Terry Pratchett"
X-CM-Score: 0.00
X-CNFS-Analysis: v=2.4 cv=ROmgoqu+ c=1 sm=1 tr=0 ts=6437137a
 a=AGp1duJPimIJhwGXxSk9fg==:117 a=AGp1duJPimIJhwGXxSk9fg==:17
 a=DAwyPP_o2Byb1YXLmDAA:9 a=P1kZ4gAsAAAA:8 a=Qs8GJauRAAAA:8 a=RLQEIbXJAAAA:8
 a=3uZhOoJFLEmANmskaukA:9 a=CjuIK1q_8ugA:10 a=CF7FYfFTbIMA:10
 a=iiBAVrzh2ScA:10 a=yMhMjlubAAAA:8 a=SSmOFEACAAAA:8 a=P4FZdNvPIfUxQTQG2wQA:9
 a=hL4sCn4nxWzGDnUj:21 a=gKO2Hq4RSVkA:10 a=UiCQ7L4-1S4A:10 a=hTZeC7Yk6K0A:10
 a=frz4AuCg-hUA:10 a=fn9vMg-Z9CMH7MoVPInU:22 a=-MsOl3yrPmtpHepMbiy1:22
 a=5X70jg_6RhHhYle3RtBs:22
X-AUTH: perdrix52@:2500
From: "David C. Partridge" <david.partridge@perdrix.co.uk>
To: "'Sulau'" <sulau@freenet.de>
Cc: <tiff@lists.osgeo.org>
References: <!&!AAAAAAAAAAAYAAAAAAAAAEUNXr1cc6FEs82BI4LfFJfCgAAAEAAAAM418k/4OelCqjx5kNnQZp4BAAAAAA==@freenet.de>
In-Reply-To: <!&!AAAAAAAAAAAYAAAAAAAAAEUNXr1cc6FEs82BI4LfFJfCgAAAEAAAAM418k/4OelCqjx5kNnQZp4BAAAAAA==@freenet.de>
Date: Wed, 12 Apr 2023 21:24:24 +0100
Message-ID: <00a001d96d7c$c68c8350$53a589f0$@perdrix.co.uk>
MIME-Version: 1.0
X-Mailer: Microsoft Outlook 16.0
Content-Language: en-gb
Thread-Index: AQKXQ+zvzFGi/wVMxTKammeNCqpYeK2scR/Q
X-CMAE-Envelope: MS4xfDHuh+cYzfZru6u/1VcUjB636AP0I8TML8Z49ga/ETpyhWu4tzEQGfxFWTDrC5at1rlu47zRHjcUZM9JY1Y8oApdvB93rU2u0lS3evsPb2tWsDYESqJ+
 Cd9GVg6mjBYhabY6hsmDtJkwiSE/VlnrMP1qkweQfRw7uH8Od7nfInXjTThYWK4Tvpz505HmQVCRCA==
Subject: Re: [Tiff] TIffWriteDirectory() causes problems
X-BeenThere: tiff@lists.osgeo.org
X-Mailman-Version: 2.1.34
Precedence: list
List-Id: TIFF and libtiff discussion <tiff.lists.osgeo.org>
List-Unsubscribe: <https://lists.osgeo.org/mailman/options/tiff>,
 <mailto:tiff-request@lists.osgeo.org?subject=unsubscribe>
List-Post: <mailto:tiff@lists.osgeo.org>
List-Help: <mailto:tiff-request@lists.osgeo.org?subject=help>
List-Subscribe: <https://lists.osgeo.org/mailman/listinfo/tiff>,
 <mailto:tiff-request@lists.osgeo.org?subject=subscribe>
Content-Type: multipart/mixed; boundary="===============4545124849456721287=="
Errors-To: tiff-bounces@lists.osgeo.org
Sender: "Tiff" <tiff-bounces@lists.osgeo.org>

This is a multipart message in MIME format.

--===============4545124849456721287==
Content-Type: multipart/alternative;
	boundary="----=_NextPart_000_00A1_01D96D85.28518790"
Content-Language: en-gb

This is a multipart message in MIME format.

------=_NextPart_000_00A1_01D96D85.28518790
Content-Type: text/plain;
	charset="us-ascii"
Content-Transfer-Encoding: 7bit

I've changed the code so that it reads:

                    // Go back to the first (main) directory, and set
correct value of the

                    // EXIFIFD pointer. Note that the directory is reloaded
from the file!

                    //

                    TIFFSetDirectory(m_tiff, 0);

                    TIFFSetField(m_tiff, TIFFTAG_EXIFIFD, dir_offset_EXIF);

                    TIFFWriteDirectory(m_tiff);

                    TIFFSetDirectory(m_tiff, 0);
             }

 

So that should sort the problem? Is that right?

 

Thanks,David

 

From: Sulau <sulau@freenet.de> 
Sent: 12 April 2023 17:26
To: 'David C. Partridge' <david.partridge@perdrix.co.uk>
Cc: tiff@lists.osgeo.org
Subject: Re: [Tiff] TIffWriteDirectory() causes problems

 

Hi David

 

The TIFF documentation of TIFF WriteDirectory() says: 

"
<http://www.simplesystems.org/libtiff/functions/TIFFWriteDirectory.html#c.TI
FFWriteDirectory> TIFFWriteDirectory() will write the contents of the
current directory (IFD) to the file and setup to create a new directory
(IFD) using
<http://www.simplesystems.org/libtiff/functions/TIFFCreateDirectory.html#c.T
IFFCreateDirectory> TIFFCreateDirectory(). "

 

This means that then m_tiff points to a new, empty directory and therefore
TiffScanlineSize() returns zero.

 

If you want to go back to the previously written IFD you have to use
TIFFSetDirectory(m_tiff, dirnumber), which re-reads the IFD (dirnumber) from
file.

Or you could first write the image data straight after "TIFFSetField(m_tiff,
TIFFTAG_EXIFID, dir_offset_EXIF);" and then call TIFFWriteDirectory() just
before TIFFClose().

 

Regards

Su


------=_NextPart_000_00A1_01D96D85.28518790
Content-Type: text/html;
	charset="us-ascii"
Content-Transfer-Encoding: quoted-printable

<html xmlns:v=3D"urn:schemas-microsoft-com:vml" =
xmlns:o=3D"urn:schemas-microsoft-com:office:office" =
xmlns:w=3D"urn:schemas-microsoft-com:office:word" =
xmlns:m=3D"http://schemas.microsoft.com/office/2004/12/omml" =
xmlns=3D"http://www.w3.org/TR/REC-html40"><head><meta =
http-equiv=3DContent-Type content=3D"text/html; =
charset=3Dus-ascii"><meta name=3DGenerator content=3D"Microsoft Word 15 =
(filtered medium)"><style><!--
/* Font Definitions */
@font-face
	{font-family:"Cambria Math";
	panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
	{font-family:Calibri;
	panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
	{font-family:"Cascadia Mono";
	panose-1:2 11 6 9 2 0 0 2 0 4;}
@font-face
	{font-family:Consolas;
	panose-1:2 11 6 9 2 2 4 3 2 4;}
@font-face
	{font-family:"Lucida Sans Unicode";
	panose-1:2 11 6 2 3 5 4 2 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
	{margin:0cm;
	font-size:11.0pt;
	font-family:"Calibri",sans-serif;
	mso-ligatures:standardcontextual;
	mso-fareast-language:EN-US;}
span.pre
	{mso-style-name:pre;}
span.EmailStyle22
	{mso-style-type:personal-reply;
	font-family:"Calibri",sans-serif;
	color:windowtext;}
MsoChpDefault
	{mso-style-type:export-only;
	font-size:10.0pt;}
@page WordSection1
	{size:612.0pt 792.0pt;
	margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.WordSection1
	{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext=3D"edit" spidmax=3D"1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext=3D"edit">
<o:idmap v:ext=3D"edit" data=3D"1" />
</o:shapelayout></xml><![endif]--></head><body lang=3DEN-GB =
link=3D"#0563C1" vlink=3D"#954F72" style=3D'word-wrap:break-word'><div =
class=3DWordSection1><p class=3DMsoNormal =
style=3D'text-autospace:none'>I&#8217;ve changed the code so that it =
reads:<br><br><span style=3D'font-size:9.5pt;font-family:"Cascadia =
Mono";color:black;mso-ligatures:none;mso-fareast-language:EN-GB'>&nbsp;&n=
bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb=
sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span =
style=3D'font-size:9.5pt;font-family:"Cascadia =
Mono";color:green;mso-ligatures:none;mso-fareast-language:EN-GB'>// Go =
back to the first (main) directory, and set correct value of =
the</span><span style=3D'font-size:9.5pt;font-family:"Cascadia =
Mono";color:black;mso-ligatures:none;mso-fareast-language:EN-GB'><o:p></o=
:p></span></p><p class=3DMsoNormal style=3D'text-autospace:none'><span =
style=3D'font-size:9.5pt;font-family:"Cascadia =
Mono";color:black;mso-ligatures:none;mso-fareast-language:EN-GB'>&nbsp;&n=
bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb=
sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span =
style=3D'font-size:9.5pt;font-family:"Cascadia =
Mono";color:green;mso-ligatures:none;mso-fareast-language:EN-GB'>// =
EXIFIFD pointer. Note that the directory is reloaded from the =
file!</span><span style=3D'font-size:9.5pt;font-family:"Cascadia =
Mono";color:black;mso-ligatures:none;mso-fareast-language:EN-GB'><o:p></o=
:p></span></p><p class=3DMsoNormal style=3D'text-autospace:none'><span =
style=3D'font-size:9.5pt;font-family:"Cascadia =
Mono";color:black;mso-ligatures:none;mso-fareast-language:EN-GB'>&nbsp;&n=
bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb=
sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span =
style=3D'font-size:9.5pt;font-family:"Cascadia =
Mono";color:green;mso-ligatures:none;mso-fareast-language:EN-GB'>//</span=
><span style=3D'font-size:9.5pt;font-family:"Cascadia =
Mono";color:black;mso-ligatures:none;mso-fareast-language:EN-GB'><o:p></o=
:p></span></p><p class=3DMsoNormal style=3D'text-autospace:none'><span =
style=3D'font-size:9.5pt;font-family:"Cascadia =
Mono";color:black;mso-ligatures:none;mso-fareast-language:EN-GB'>&nbsp;&n=
bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb=
sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; TIFFSetDirectory(m_tiff, =
0);<o:p></o:p></span></p><p class=3DMsoNormal =
style=3D'text-autospace:none'><span =
style=3D'font-size:9.5pt;font-family:"Cascadia =
Mono";color:black;mso-ligatures:none;mso-fareast-language:EN-GB'>&nbsp;&n=
bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb=
sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; TIFFSetField(m_tiff, </span><span =
style=3D'font-size:9.5pt;font-family:"Cascadia =
Mono";color:#6F008A;mso-ligatures:none;mso-fareast-language:EN-GB'>TIFFTA=
G_EXIFIFD</span><span style=3D'font-size:9.5pt;font-family:"Cascadia =
Mono";color:black;mso-ligatures:none;mso-fareast-language:EN-GB'>, =
dir_offset_EXIF);<o:p></o:p></span></p><p class=3DMsoNormal =
style=3D'text-autospace:none'><span =
style=3D'font-size:9.5pt;font-family:"Cascadia =
Mono";color:black;mso-ligatures:none;mso-fareast-language:EN-GB'>&nbsp;&n=
bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb=
sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
TIFFWriteDirectory(m_tiff);<o:p></o:p></span></p><p =
class=3DMsoNormal><span style=3D'font-size:9.5pt;font-family:"Cascadia =
Mono";color:black;mso-ligatures:none;mso-fareast-language:EN-GB'>&nbsp;&n=
bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb=
sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; TIFFSetDirectory(m_tiff, =
0);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=
&nbsp; }<o:p></o:p></span></p><p class=3DMsoNormal><span =
style=3D'font-size:9.5pt;font-family:"Cascadia =
Mono";color:black;mso-ligatures:none;mso-fareast-language:EN-GB'><o:p>&nb=
sp;</o:p></span></p><p class=3DMsoNormal><span =
style=3D'font-size:9.5pt;font-family:"Cascadia =
Mono";color:black;mso-ligatures:none;mso-fareast-language:EN-GB'>So that =
should sort the problem? Is that right?<o:p></o:p></span></p><p =
class=3DMsoNormal><span style=3D'font-size:9.5pt;font-family:"Cascadia =
Mono";color:black;mso-ligatures:none;mso-fareast-language:EN-GB'><o:p>&nb=
sp;</o:p></span></p><p class=3DMsoNormal><span =
style=3D'font-size:9.5pt;font-family:"Cascadia =
Mono";color:black;mso-ligatures:none;mso-fareast-language:EN-GB'>Thanks,D=
avid</span><o:p></o:p></p><p =
class=3DMsoNormal><o:p>&nbsp;</o:p></p><div><div =
style=3D'border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0cm =
0cm 0cm'><p class=3DMsoNormal><b><span lang=3DEN-US =
style=3D'mso-ligatures:none;mso-fareast-language:EN-GB'>From:</span></b><=
span lang=3DEN-US =
style=3D'mso-ligatures:none;mso-fareast-language:EN-GB'> Sulau =
&lt;sulau@freenet.de&gt; <br><b>Sent:</b> 12 April 2023 =
17:26<br><b>To:</b> 'David C. Partridge' =
&lt;david.partridge@perdrix.co.uk&gt;<br><b>Cc:</b> =
tiff@lists.osgeo.org<br><b>Subject:</b> Re: [Tiff] TIffWriteDirectory() =
causes problems<o:p></o:p></span></p></div></div><p =
class=3DMsoNormal><o:p>&nbsp;</o:p></p><p class=3DMsoNormal><span =
lang=3DDE style=3D'color:#1F497D'>Hi David<o:p></o:p></span></p><p =
class=3DMsoNormal><span lang=3DDE =
style=3D'color:#1F497D'><o:p>&nbsp;</o:p></span></p><p =
class=3DMsoNormal><span style=3D'color:#1F497D'>The TIFF documentation =
of TIFF WriteDirectory() says: <o:p></o:p></span></p><p =
class=3DMsoNormal><span style=3D'color:#1F497D'>&#8220;</span><span =
lang=3DDE><a =
href=3D"http://www.simplesystems.org/libtiff/functions/TIFFWriteDirectory=
html#c.TIFFWriteDirectory" title=3DTIFFWriteDirectory><span =
class=3Dpre><b><span lang=3DEN-GB =
style=3D'font-size:10.0pt;font-family:Consolas;color:#CA7900;letter-spaci=
ng:.1pt;border:none windowtext =
1.0pt;padding:0cm'>TIFFWriteDirectory()</span></b></span></a></span><span=
 style=3D'font-size:10.5pt;font-family:"Lucida Sans =
Unicode",sans-serif;color:black;letter-spacing:-.1pt;background:white'>&n=
bsp;will write the contents of the current directory (IFD) to the file =
and <b>setup to create a new directory (IFD)</b> using&nbsp;</span><span =
lang=3DDE><a =
href=3D"http://www.simplesystems.org/libtiff/functions/TIFFCreateDirector=
y.html#c.TIFFCreateDirectory" title=3DTIFFCreateDirectory><span =
class=3Dpre><b><span lang=3DEN-GB =
style=3D'font-size:10.0pt;font-family:Consolas;color:#CA7900;letter-spaci=
ng:.1pt;border:none windowtext =
1.0pt;padding:0cm'>TIFFCreateDirectory()</span></b></span></a></span><spa=
n style=3D'font-size:10.5pt;font-family:"Lucida Sans =
Unicode",sans-serif;color:black;letter-spacing:-.1pt;background:white'>.&=
nbsp;&#8220;<o:p></o:p></span></p><p class=3DMsoNormal><span =
style=3D'color:#1F497D'><o:p>&nbsp;</o:p></span></p><p =
class=3DMsoNormal><span style=3D'color:#1F497D'>This means that then =
m_tiff points to a new, empty directory and therefore TiffScanlineSize() =
returns zero.<o:p></o:p></span></p><p class=3DMsoNormal><span =
style=3D'color:#1F497D'><o:p>&nbsp;</o:p></span></p><p =
class=3DMsoNormal><span style=3D'color:#1F497D'>If you want to go back =
to the previously written IFD you have to use TIFFSetDirectory(m_tiff, =
dirnumber), which re-reads the IFD (dirnumber) from =
file.<o:p></o:p></span></p><p class=3DMsoNormal><span =
style=3D'color:#1F497D'>Or you could first write the image data straight =
after &#8220;TIFFSetField(m_tiff, TIFFTAG_EXIFID, =
dir_offset_EXIF);&#8221; and then call TIFFWriteDirectory() just before =
TIFFClose().<o:p></o:p></span></p><p class=3DMsoNormal><span =
style=3D'color:#1F497D'><o:p>&nbsp;</o:p></span></p><p =
class=3DMsoNormal><span =
style=3D'color:#1F497D'>Regards<o:p></o:p></span></p><p =
class=3DMsoNormal><span =
style=3D'color:#1F497D'>Su<o:p></o:p></span></p></div></body></html>
------=_NextPart_000_00A1_01D96D85.28518790--


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

_______________________________________________
Tiff mailing list
Tiff@lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/tiff

--===============4545124849456721287==--

