Return-Path: <SRS0=HJ1s=AE=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 gGj9KA31N2SsUAAAwT5NuQ
	(envelope-from <SRS0=HJ1s=AE=lists.osgeo.org=tiff-bounces@osgeo.org>)
	for <filtered@awaresystems.be>; Thu, 13 Apr 2023 12:26:53 +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:cc:to:message-id:date:from:in-reply-to:references:mime-version:
	 x-halone-refid:x-halone-sa:from:x-halone-sa:x-halone-refid;
	bh=mA067QXPORuMA64C2TsEMyBW7nBq6o9ADJs6iB/njV0=;
	b=gsmcXjJprt++BMuB+tkg+cNiSdeWTkZr2nfGdy7tYqCknbabuE7E74h+TjV8/AayuWDKLLNpbmpW2
	 Gadc8cazstc4YgneZ/uijg6r9jmJhNIECZLYqo8KiUbkgm5gKUrE9QpJcB6Kg8cK6rl9BCbdhCKMpl
	 5TzcO7S4n2bh181Vgkhs1CJ3iQ9yZ05233J/WkCrjToToeWWmss4gIW19bga5aCf0PH70fn2d0rcjB
	 AuQsblsA07GrDKkqEMSu9xBw2vlUFR5vM2qAgQ0VJtoy0yxf8QVGooHsBadkOG8ibH+vv1M21t6iGY
	 ZvoVxOkBipMsa0V+ESLFth6Yh3TVh/Q==
X-HalOne-SA: -0.3
X-HalOne-RefID: 155866::1681388812-C69210C0-E566E4D1/0/0
X-HalOne-ID: 777f05c9-d9f6-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 777f05c9-d9f6-11ed-9491-98039b062cb2;
	Thu, 13 Apr 2023 12:26:52 +0000 (UTC)
Received: from osgeo6.osgeo.osuosl.org (localhost [127.0.0.1])
	by lists.osgeo.org (Postfix) with ESMTP id 9BAD5612142B;
	Thu, 13 Apr 2023 05:26:48 -0700 (PDT)
Authentication-Results: lists.osgeo.org;
	dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="ko4lklC5";
	dkim-atps=neutral
Received: from mail-lj1-f173.google.com (mail-lj1-f173.google.com
 [209.85.208.173])
 by lists.osgeo.org (Postfix) with ESMTPS id 544C1612141E
 for <tiff@lists.osgeo.org>; Thu, 13 Apr 2023 05:26:46 -0700 (PDT)
Received: by mail-lj1-f173.google.com with SMTP id q15so11614093ljp.5
 for <tiff@lists.osgeo.org>; Thu, 13 Apr 2023 05:26:46 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=gmail.com; s=20221208; t=1681388804; x=1683980804;
 h=cc:to:subject:message-id:date:from:in-reply-to:references
 :mime-version:from:to:cc:subject:date:message-id:reply-to;
 bh=MFAgGt4z+hGH0mlisiEbpuR+umUm3QkBr32Sp0HFY3U=;
 b=ko4lklC5dr1fYHQrEb97JaoeFe1SVhd8BSrgNWds/xnS+Mu+1JCukZDqPSrwBIR3GZ
 Y4heaPqvLTsYtGOCjyCwWgbkejn0OqapY5z5BfDs+E5Qdzpf8iZ4auYabBtWW+HlOTVN
 lrUIiSkZdHJOYEG0z+6jSgRosOFrsLJmm5g0c3/i4c3KbPELvwlo4HY54PvYYYTAbhw+
 BL/BdXbkXti7xxpusEMFKjr4kz3FxOHdGvHciAepRy0dENk6ah6o+ET+6STE01NK2XAh
 9ZMsdonSPAXXRIOFfQGuBf1OnKT6Q0YXvbIsbGdoRdw4pRputKs2Rr/QLQkXHPLFH3ud
 p5LQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20221208; t=1681388804; x=1683980804;
 h=cc:to:subject:message-id:date:from:in-reply-to:references
 :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id
 :reply-to;
 bh=MFAgGt4z+hGH0mlisiEbpuR+umUm3QkBr32Sp0HFY3U=;
 b=M5giLmv02DdhrAYcDvGuIN55uqtn+IEsfdOhQAWEniZBUMtRsL4qq35id3i3OvZvNM
 XSlv+8w1CN8saepTqBCIYHTeWfhmGjCpKKM2K2mWNrACwpJiKw3U04r9Q2hU6hmOITbl
 q673Z8nqu/EEUf9zklFEZQ7YS+iMizjz8ZCpj1RCa3d4FJ9TOW6WPhTxX6BJVCfrrvtW
 Y6oXB5YNy1HBsVXK5LUnZiJSiXczb8H7cznXOFU+qSrQYMq9tEC2tiMcH3VKzuoMCJUk
 t0X81hXwngruTKui4DhbqbdVCv6kFVn7WJ4gcOmSuJUKGe9WU00En91X226PjDz4MqAW
 eeOw==
X-Gm-Message-State: AAQBX9eyIA1MJZvy3nj9xYL+nLFhmTAc5jXLV27MeDQgsL6b1spXbKx7
 2l2+FPIZqSM1Kob734bYEAyzQ00mxxPkeTxkK/A=
X-Google-Smtp-Source: AKy350YL85uHLtWJCYhprXYyFlsZCwUsrSthFRYqyz5OdqMX2/+kbEorfNUJ0/x1gQCGfUfUoti7SIkID8/vab+jhAI=
X-Received: by 2002:a2e:9d45:0:b0:29a:9053:ed1b with SMTP id
 y5-20020a2e9d45000000b0029a9053ed1bmr715526ljj.3.1681388803877; Thu, 13 Apr
 2023 05:26:43 -0700 (PDT)
MIME-Version: 1.0
References: <!&!AAAAAAAAAAAYAAAAAAAAAEUNXr1cc6FEs82BI4LfFJfCgAAAEAAAAM418k/4OelCqjx5kNnQZp4BAAAAAA==@freenet.de>
 <00a001d96d7c$c68c8350$53a589f0$@perdrix.co.uk>
 <000001d96dea$e109f000$a31dd000$@perdrix.co.uk>
 <007901d96e01$afd64c60$0f82e520$@perdrix.co.uk>
In-Reply-To: <007901d96e01$afd64c60$0f82e520$@perdrix.co.uk>
From: Olivier Paquet <olivier.paquet@gmail.com>
Date: Thu, 13 Apr 2023 08:26:32 -0400
Message-ID: <CAAcuQeZ5t7oK_4xT3AX2UnJB4CxKnyJ8TG6Qc06LUHitijavng@mail.gmail.com>
To: "David C. Partridge" <david.partridge@perdrix.co.uk>
Cc: tiff@lists.osgeo.org
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="===============4191827240372546954=="
Errors-To: tiff-bounces@lists.osgeo.org
Sender: "Tiff" <tiff-bounces@lists.osgeo.org>

--===============4191827240372546954==
Content-Type: multipart/alternative; boundary="000000000000626fab05f936d645"

--000000000000626fab05f936d645
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

Hi,
    You can prefill StripOffsets and StripByteCounts yourself by using
TIFFWriteRawStrip() calls with null data pointer and 0 size for all strips.
This should let you avoid changing directory size when you later write
actual data.

Olivier

Le jeu. 13 avr. 2023, =C3=A0 08 h 16, David C. Partridge <
david.partridge@perdrix.co.uk> a =C3=A9crit :

> I eventually worked out what was happening:
>
> The very act of writing the data added two additional fields to the base
> IFD - specifically:
>
>
>
> StripOffsets (3 Long): 514, 16771762, 33543010
>
> StripByteCounts (3 Long): 16771248, 16771248, 2496960
>
>
>
> They were added by the libtiff code internally (not by my code).
>
>
>
> Which meant that the base IFD was larger after writing the data than it
> was before. Thus, TIFFWriteDirectory over-wrote the EXIF IFD resulting in
> the EXIF IFD being overwritten =E2=80=A6 and the file therefore failed
> validation.   Therefore, there's no way to avoid the base IFD being at th=
e
> end of the file.
>

--000000000000626fab05f936d645
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div>Hi,</div><div>=C2=A0 =C2=A0 You can prefill StripOffs=
ets and StripByteCounts yourself by using TIFFWriteRawStrip() calls with nu=
ll data pointer and 0 size for all strips. This should let you avoid changi=
ng directory size when you later write actual data.</div><div><br></div><di=
v>Olivier</div><br><div class=3D"gmail_quote"><div dir=3D"ltr" class=3D"gma=
il_attr">Le jeu. 13 avr. 2023, =C3=A0 08 h 16, David C. Partridge &lt;<a hr=
ef=3D"mailto:david.partridge@perdrix.co.uk" target=3D"_blank">david.partrid=
ge@perdrix.co.uk</a>&gt; a =C3=A9crit=C2=A0:<br></div><blockquote class=3D"=
gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(20=
4,204,204);padding-left:1ex"><div><div lang=3D"EN-GB"><div><p class=3D"MsoN=
ormal">I eventually worked out what was happening:<br><br>The very act of w=
riting the data added two additional fields to the base IFD - specifically:=
<u></u><u></u></p><p class=3D"MsoNormal"><u></u>=C2=A0<u></u></p><p class=
=3D"MsoNormal">StripOffsets (3 Long): 514, 16771762, 33543010<u></u><u></u>=
</p><p class=3D"MsoNormal">StripByteCounts (3 Long): 16771248, 16771248, 24=
96960 <u></u><u></u></p><p class=3D"MsoNormal"><u></u>=C2=A0<u></u></p><p c=
lass=3D"MsoNormal">They were added by the libtiff code internally (not by m=
y code).<u></u><u></u></p><p class=3D"MsoNormal"><u></u>=C2=A0<u></u></p><p=
 class=3D"MsoNormal">Which meant that the base IFD was larger after writing=
 the data than it was before. Thus, TIFFWriteDirectory over-wrote the EXIF =
IFD resulting in the EXIF IFD being overwritten =E2=80=A6 and the file ther=
efore failed validation.=C2=A0=C2=A0 Therefore, there&#39;s no way to avoid=
 the base IFD being at the end of the file.</p></div></div></div></blockquo=
te><div>=C2=A0<br></div></div></div>

--000000000000626fab05f936d645--

--===============4191827240372546954==
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

--===============4191827240372546954==--
