Return-Path: owner-tiff@olympiakos.com
Return-Path: <owner-tiff@olympiakos.com>
Received: from localhost (localhost [127.0.0.1])
	by at1895.spb.edu (8.12.0.Beta7/8.12.0.Beta7) with ESMTP id f5G993Qw019448
	for <dron@localhost>; Sat, 16 Jun 2001 13:28:41 +0400
Received: from eudoramail.com [209.185.123.45]
	by localhost with POP3 (fetchmail-5.8.1)
	for dron@localhost (single-drop); Sat, 16 Jun 2001 13:28:41 +0400 (MSD)
Received: from gate7.olympiakos.com ([207.176.88.85]) by shared1-mail.whowhere.com; Fri Jun 15 17:40:16 2001
Received: from localhost (daemon@localhost)
	by gate7.olympiakos.com (8.9.3/8.9.3) with SMTP id UAA21475;
	Fri, 15 Jun 2001 20:17:10 -0400
Received: by gate7.olympiakos.com (bulk_mailer v1.9); Fri, 15 Jun 2001 20:10:49 -0400
Received: (from majordom@localhost)
	by gate7.olympiakos.com (8.9.3/8.9.3) id UAA21287
	for tiff-outgoing; Fri, 15 Jun 2001 20:10:49 -0400
X-Authentication-Warning: gate7.olympiakos.com: majordom set sender to owner-tiff@olympiakos.com using -f
Received: from snoopy.jcpenney.com (jcpint2a.jcpenney.com [146.235.25.1])
	by gate7.olympiakos.com (8.9.3/8.9.3) with ESMTP id UAA21284
	for <tiff@olympiakos.com>; Fri, 15 Jun 2001 20:10:46 -0400
Received: from uns-dv1.jcpenney.com (uns-dv1.jcpenney.com [10.33.239.136])
	by snoopy.jcpenney.com (8.11.3/8.11.3) with ESMTP id f5FJoEW29239;
	Fri, 15 Jun 2001 14:50:14 -0500 (CDT)
Received: (from jschumac@localhost)
	by uns-dv1.jcpenney.com (8.9.3+Sun/8.9.1) id OAA11735;
	Fri, 15 Jun 2001 14:52:27 -0500 (CDT)
Date: Fri, 15 Jun 2001 14:52:27 -0500
From: Joel Schumacher <jschumac@jcpenney.com>
To: Pak Yan Choi <pakyan+@andrew.cmu.edu>
Cc: Sam Leffler <sam@errno.com>, tiff@olympiakos.com
Subject: Re: Image manipulation package based on libtiff?
Message-ID: <20010615145227.D28608@jcpenney.com>
References: <0e4101c0f5b5$8754ef30$24a6d4d1@melange> <Pine.LNX.3.96L.1010615132612.5002A-100000@unix48.andrew.cmu.edu>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
X-Mailer: Mutt 1.0i
In-Reply-To: <Pine.LNX.3.96L.1010615132612.5002A-100000@unix48.andrew.cmu.edu>; from pakyan+@andrew.cmu.edu on Fri, Jun 15, 2001 at 01:34:17PM -0400
Sender: owner-tiff@olympiakos.com
Status: RO
Content-Length: 3506
Lines: 84

The online docs do state:

  Note that unlike the stdio library TIFF image files may not be opened
  for both reading and writing; there is no support for altering the
  contents of a TIFF file.

This probably seems doable, but seems a difficult task.  It seems the
method employed with libtiff would be to read page(s) from one file
(or from memory) and add them to another .  So you'd have to write a
whole new file, putting your changes into that file, not modify the
existing one.

It probably *could* be done, and libtiff might be able to be modified
to handle it, but think of all you have to take care of.

With a few small changes, your whole image compression could grow,
causing the image to no longer fit where it once was.  Or to shrink,
leaving big gaps of unused space in the middle of the image, which is
inefficient.

Seeing as though TIFF is a multi-page format, you have to be aware of
what space is being used by other pages.  You can't just keep writing
one page if it's now bigger for fear of overwriting another.

And, theoretically, there could be image tags that point to data
stored who knows where throughout the file?  You have to be careful
not to step on those.

Probably the most efficient approach would be to give up the space
used by the page originally, reclaim that space (for both the image,
probably the image header, and data pointed to by the tags in the
header) and do a relocate of all the other page(s), image headers,
data, etc. in the rest of the file, then put your changes for the
page you're altering at the end.

But by the time you do all that work, you'd probably be better off
creating a new file, with all the pages in some sort of logical order.

Seems incredibly messy, in my opinion, and would probably take longer
than an entire file rewrite.

What is this, some sort of classroom project?  Seems like you have a
goal to prove you can write a piece of code (which you seem to be
asking others to do for you), but you're very open to how you do it.
You don't even care if it's TIFF format or some other format.  Sounds
like a sort of open-ended classroom assignment, not real-world type of
stuff.

Well, most other formats would be easier, as they are not multi-page.
But you'd still probably end up re-writing the entire file, not doing
a modification.

Maybe try some uncompressed format like Windows BMP files.  You should
be able to directly address portions of those files and modify specific
areas without re-encoding/rewriting the entire file.


Pak Yan Choi (pakyan+@andrew.cmu.edu) wrote :
> Sam,
> 
> Are you saying libtiff is capable of performing read and write operations
> on an image? From what I read from a tiff library doc
> (http://www.libtiff.org/libtiff.html#FIO), it seems the libtiff cannot
> open a file for both reading and writing and there is no support for
> altering the contents of a tiff file.
> 
> Would you mind clearing that up please? Is modification to the library
> needed to do read and write?
> 
> Patrick
> 
> On Fri, 15 Jun 2001, Sam Leffler wrote:
> 
> > The SGI image library did just what you describe; they used libtiff
> > unchanged (so far as I recall). Their software was/is a product and isn't
> > available for free.
> > 
> >     Sam

-- 
______________________________________________________________________
Joel Schumacher                    JCPenney Co. - UNIX Network Systems
jschumac@jcpenney.com              12700 Park Central Pl   M/S 6021
(972) 591-7543                     Dallas TX  75251

