Return-Path: <awaresystems.be+caf_=filtered=awaresystems.be@gmail.com>
Delivered-To: filtered@awaresystems.be
Received: from mx1.pub.mailpod2-cph3.one.com ([10.27.25.11])
	by mailstorage18.cst.mailpod2-cph3.one.com (Dovecot) with LMTP id JormJkQUYlrBxwEAQS8vrQ
	for <filtered@awaresystems.be>; Fri, 19 Jan 2018 16:02:55 +0000
X-HalOne-ID: 3533d989-fd32-11e7-afe7-e0d848957041
Received: from mail-oi0-f48.google.com (unknown [209.85.218.48])
	by mx1.pub.mailpod2-cph3.one.com (Halon) with ESMTPS
	id 3533d989-fd32-11e7-afe7-e0d848957041;
	Fri, 19 Jan 2018 16:02:54 +0000 (UTC)
Received: by mail-oi0-f48.google.com with SMTP id j129so1419630oib.12
        for <filtered@awaresystems.be>; Fri, 19 Jan 2018 08:02:54 -0800 (PST)
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20161025;
        h=x-original-authentication-results:x-gm-message-state:delivered-to
         :mime-version:date:from:to:message-id:user-agent:subject:precedence
         :list-id:list-unsubscribe:list-archive:list-post:list-help
         :list-subscribe:content-transfer-encoding:sender:errors-to;
        bh=PwIijANY86X/mDdEtg4LseLrewsswB0zlANizSg/mhY=;
        b=tNVSoOC0BSZZM+9jAxtdI9Ou7btD2uHlt9jFkP9mXuIXW8bNah44wqwmtW7aerKN78
         UDzWekZASG7EFpHoEP82uL1zRPq4OZWIF/kxOPE2i0EYj2mM/M6tnvSKUap9yEaIPkd8
         4UYM1ksZAy6aA0en1rd68gp1nYxonzpi2zFvKvpMPhLfdk4/MWlG6Etb4cxSQRlnh7mQ
         xRfw/IZ/7yyht+JlCFzSPewXiyAaTR6lO9TWLO7FSC/Y/yTdOls3sYHshevJPtKO1g5K
         Q6TRyoNxVHhvLf14ES1knsTlMCv/6hxj8H+dXFdU0+iyqbaXRA0kyKtNjr8bjiqONVLJ
         J51g==
X-Original-Authentication-Results: mx.google.com;       spf=neutral (google.com: 94.23.4.142 is neither permitted nor denied by best guess record for domain of tiff-bounces@lists.maptools.org) smtp.mailfrom=tiff-bounces@lists.maptools.org
X-Gm-Message-State: AKwxyteibV5+yuZoOSWBfUW19auXRwJbvp7kiLQgCW/rYbqKoJUFmKc9
	+gy0zmP2DU587Ls3Tc4zhJrTolFu6nAmJ+VEz9DEtvYb11MsfeE=
X-Received: by 10.202.6.4 with SMTP id 4mr5398800oig.316.1516377773619;
        Fri, 19 Jan 2018 08:02:53 -0800 (PST)
X-Forwarded-To: filtered@awaresystems.be
X-Forwarded-For: awaresystems.be@gmail.com filtered@awaresystems.be
Delivered-To: awaresystems.be@gmail.com
Received: by 10.202.194.198 with SMTP id s189csp1033929oif;
        Fri, 19 Jan 2018 08:02:52 -0800 (PST)
X-Google-Smtp-Source: ACJfBovIX7cqjRK0W0nedG6zWt3SNs2pKgVWau4wOp/gfmSGz1qawFv6HDfuSStrbt1hrysJvp3C
X-Received: by 10.28.35.200 with SMTP id j191mr9190438wmj.146.1516377772400;
        Fri, 19 Jan 2018 08:02:52 -0800 (PST)
ARC-Seal: i=1; a=rsa-sha256; t=1516377772; cv=none;
        d=google.com; s=arc-20160816;
        b=t7zSpk3q2O27zuulj+IYNAc4DqODpinbUXeBuW50cWhzr0XPbUdzg0FCFB0moTMDEJ
         Fwcqcjkm6Zl1QYJh4kCVgJcFtElQQ7LfATMWupfF8UNzC0yIeb3sytVSng14hpdRnGOZ
         7GkPdckljDyq+u9x2pRmN6Z94LKutZ0COWbDTkH5IQI2nXv+wyn7fgiSkexmkyjds22p
         Su9mBhGE9KHT6TVTqBcbcaYhk9BDnSS8ma+MSKisGnjh8ujrTK7dBZyy3xT7bLGM3jiA
         +BjIH/ASA2NuYXpcLQYMmx/gxOtFMLDMII42F2TLxNEPlpou9DgMX9tq6EJArp2mUMMJ
         UdHg==
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816;
        h=errors-to:sender:content-transfer-encoding:list-subscribe:list-help
         :list-post:list-archive:list-unsubscribe:list-id:precedence:subject
         :user-agent:message-id:to:from:date:mime-version
         :arc-authentication-results;
        bh=PwIijANY86X/mDdEtg4LseLrewsswB0zlANizSg/mhY=;
        b=Uww36HIjGX8YZeR9nsRFJvfmSp09Vaas/vOPkIIwLAq1KvuCvRGnJHOliB9ioyKI6v
         l+a7KkrqG/BGyh/sf8U/3iD3zxBU/aX3VvYyzrxhyxBArs9uBwzNQwneDd1U3QUQf8rG
         AD+r3xMB9pKZX6Q4E2liiRp69rN1pao9MdSNYFr78wxOzQH4oIE/IYHwM4fC15owKEQ1
         y2CwvcRe5ne+XRlav4Xm4lEYcUZfoXrsuDnPypbO/ZxrD0J1TaxnZFGy63+Dx4D3nv5R
         +ahctfmFhSqDkgP0kObK1mXo6Vv5Zz6TbUbAYBX0MhnQu5M89HpxA16wy+EpDlj6yh1J
         bN3g==
ARC-Authentication-Results: i=1; mx.google.com;
       spf=neutral (google.com: 94.23.4.142 is neither permitted nor denied by best guess record for domain of tiff-bounces@lists.maptools.org) smtp.mailfrom=tiff-bounces@lists.maptools.org
Return-Path: <tiff-bounces@lists.maptools.org>
Received: from lists.maptools.org (ks365428.kimsufi.com. [94.23.4.142])
        by mx.google.com with ESMTP id w32si8487651wrb.20.2018.01.19.08.02.35;
        Fri, 19 Jan 2018 08:02:52 -0800 (PST)
Received-SPF: neutral (google.com: 94.23.4.142 is neither permitted nor denied by best guess record for domain of tiff-bounces@lists.maptools.org) client-ip=94.23.4.142;
Authentication-Results: mx.google.com;
       spf=neutral (google.com: 94.23.4.142 is neither permitted nor denied by best guess record for domain of tiff-bounces@lists.maptools.org) smtp.mailfrom=tiff-bounces@lists.maptools.org
Received: from [10.1.0.241] (localhost.localdomain [127.0.0.1])
	by lists.maptools.org (Postfix) with ESMTP id BC88035C0E2;
	Fri, 19 Jan 2018 11:01:33 -0500 (EST)
Received: from a-painless.mh.aa.net.uk (a-painless.mh.aa.net.uk [81.187.30.51])
	by lists.maptools.org (Postfix) with ESMTPS id 722B135C024
	for <tiff@lists.maptools.org>; Fri, 19 Jan 2018 10:34:57 -0500 (EST)
Received: from b-webmail.mh.aa.net.uk ([2001:8b0:0:30::77]
	helo=webmail.aa.net.uk) by a-painless.mh.aa.net.uk with esmtpsa
	(TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.89)
	(envelope-from <rleigh@codelibre.net>) id 1ecYgz-0002Vy-30
	for tiff@lists.maptools.org; Fri, 19 Jan 2018 15:34:57 +0000
Received: from [134.36.162.3] by webmail.aa.net.uk
	with HTTP (HTTP/1.1 POST); Fri, 19 Jan 2018 15:34:56 +0000
MIME-Version: 1.0
Date: Fri, 19 Jan 2018 15:34:56 +0000
From: rleigh@codelibre.net
To: tiff@lists.maptools.org
Message-ID: <2428caeab29adde489684bae98458c99@codelibre.net>
X-Sender: rleigh@codelibre.net
User-Agent: Roundcube Webmail/1.2.3
Subject: [Tiff] Modifying field values without rewriting the whole directory
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: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
Sender: tiff-bounces@lists.maptools.org
Errors-To: tiff-bounces@lists.maptools.org

Is it possible to make small edits to the field values within a 
directory without doing an expensive rewrite of the entire directory 
contents?  That is, with the libtiff API (it's fairly easy to manually 
edit it with my own code, but a bit hairier than I'd like and I'd like 
to make use of the existing libtiff functionality where possible).  I 
don't want to add any extra fields, rather to modify some already 
existing values in-place.

#include <tiff.h>
#include <tiffio.h>

int main()
{
   auto tiff = TIFFOpen("test.tiff", "r+");
   TIFFSetField(tiff, TIFFTAG_XRESOLUTION, 100.0);
   TIFFSetField(tiff, TIFFTAG_YRESOLUTION, 200.0);
   TIFFCheckpointDirectory(tiff); // or TIFFRewriteDirectory(tiff)
   TIFFClose(tiff);
}

This works, but I'm getting a whole new directly created, which I would 
prefer to avoid.  While in this case I'm changing some trivial values, 
it would also be useful to update e.g. SUBIFD tags when appending 
reduced versions of images to the file.  I don't want to copy all the 
tile offsets+sizes and all the other metadata, just a single offset.  
Similarly for updating the image description, where I can append the 
string to the file and update the pointer to it.


Thanks,
Roger
_______________________________________________
Tiff mailing list: Tiff@lists.maptools.org
http://lists.maptools.org/mailman/listinfo/tiff
http://www.remotesensing.org/libtiff/
