Return-Path: <tiff-bounces@remotesensing.org>
Received: from inmx014.isp.belgacom.be (inmx014.isp.belgacom.be [195.238.2.217])
        by mailst006.isp.belgacom.be (8.12.11/8.12.11/Skynet-MAILSTORE-2.14) with ESMTP id i7NFW7eP009268
        for <joris.at.lebbeke@skynet.be>; Mon, 23 Aug 2004 17:32:07 +0200
        (envelope-from <tiff-bounces@remotesensing.org>)
Received: from xserve.flids.com (adsl-065-083-169-202.sip.mco.bellsouth.net [65.83.169.202])
        by inmx014.isp.belgacom.be (8.12.11/8.12.11/Skynet-IN-2.32) with ESMTP id i7NFVqtM008209
        for <joris.at.lebbeke@skynet.be>; Mon, 23 Aug 2004 17:31:58 +0200
        (envelope-from <tiff-bounces@remotesensing.org>)
Received: from adsl-065-083-169-202.sip.mco.bellsouth.net (localhost [127.0.0.1])
	by xserve.flids.com (Postfix) with ESMTP
	id 03643245E40; Mon, 23 Aug 2004 11:31:30 -0400 (EDT)
X-Original-To: tiff@remotesensing.org
Delivered-To: tiff@remotesensing.org
Received: from mail.cst.ro (unknown [193.230.179.50])
	by xserve.flids.com (Postfix) with ESMTP id 60343245E1A
	for <tiff@remotesensing.org>; Mon, 23 Aug 2004 11:31:27 -0400 (EDT)
Received: from cstdev.cst.ro (cstdev.cst.ro [192.168.0.190])
	by mail.cst.ro (8.11.6+Sun/8.11.6) with ESMTP id i7NFh2J00416
	for <tiff@remotesensing.org>; Mon, 23 Aug 2004 18:43:02 +0300 (EEST)
Received: from George (monica.cst.ro [192.168.0.151])
	by cstdev.cst.ro (8.9.3+Sun/8.9.3) with ESMTP id SAA11112
	for <tiff@remotesensing.org>; Mon, 23 Aug 2004 18:19:00 +0300 (EEST)
From: "Alexandru, Ionita" <galexandru@cstdev.cst.ro>
To: <tiff@remotesensing.org>
Subject: RE: [Tiff] Tiff conversion using libTiff
Date: Mon, 23 Aug 2004 18:30:08 +0300
Message-ID: <000201c48926$15bac220$9700a8c0@cst.ro>
MIME-Version: 1.0
Content-Type: text/plain;
	charset="us-ascii"
Content-Transfer-Encoding: quoted-printable
X-Priority: 3 (Normal)
X-MSMail-Priority: Normal
X-Mailer: Microsoft Outlook, Build 10.0.6626
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441
Importance: Normal
In-Reply-To: <Pine.GSO.4.43.0408200933590.9719-100000@tiki-lounge.com>
X-BeenThere: tiff@remotesensing.org
X-Mailman-Version: 2.1.2
Precedence: list
List-Id: TIFF and libtiff discussion  <tiff.remotesensing.org>
List-Unsubscribe: <http://xserve.flids.com/mailman/listinfo/tiff>,
	<mailto:tiff-request@remotesensing.org?subject=unsubscribe>
List-Archive: <http://xserve.flids.com/pipermail/tiff>
List-Post: <mailto:tiff@remotesensing.org>
List-Help: <mailto:tiff-request@remotesensing.org?subject=help>
List-Subscribe: <http://xserve.flids.com/mailman/listinfo/tiff>,
	<mailto:tiff-request@remotesensing.org?subject=subscribe>
Sender: tiff-bounces@remotesensing.org
Errors-To: tiff-bounces@remotesensing.org
X-UIDL: de34c0e556e50e75e9d3b1b39f64454a


I've tried to set this fields using tiffset from libtiff, but this error
occurs:

D:\work>tiffset -s PhotometricInterpretation 1 TsrFile.tiff
TIFFSetField: TsrFile.tiff: Unknown pseudo-tag 4294967295. Failed to set
PhotometricInterpretation=3D1

D:\work>tiffset -s SamplesPerPixel 1 TsrFile.tiff
TIFFSetField: TsrFile.tiff: Unknown pseudo-tag 4294967295. Failed to set
SamplesPerPixel=3D1

And another thing that I didn't mentionate is that I'm using windows XP, =
and
libtiff is accessed from java, through command Line executed with
java.Runtime.getRuntime.exec(commandString). I have to do all this
opperations in this conditions.
-----Original Message-----
From: Ross A. Finlayson [mailto:raf@tiki-lounge.com]=20
Sent: Friday, August 20, 2004 7:37 PM
To: Joris
Cc: Alexandru, Ionita; Tiff mailing list
Subject: Re: [Tiff] Tiff conversion using libTiff


TIFF Directory at offset 0xb5706
  Image Width: 1640 Image Length: 2602
  Resolution: 199.975, 199.975
  Bits/Sample: 1
  Compression Scheme: LZW
  Orientation: row 0 top, col 0 lhs
  Rows/Strip: 39
  Planar Configuration: single image plane
TIFF Directory at offset 0xbcf9a
  Subfile Type: multi-page document (2 =3D 0x2)
  ...

This IFD does not have the PhotometricInterpretation field set, or
SamplesPerPixel.  The default is probably 0, and 1.

So when a previous IFD had set RGB, then when the function call is made =
to
get the PhotometricInterpretation, it could fail bcause I don't check =
the
reurn value.

        TIFFGetField(input, TIFFTAG_PHOTOMETRIC, =
&(t2p->tiff_photometric));


Then, it reuses the value of tiff_photometric from a previous IFD.

I considered you could change the line maching the above line in =
tiff2pdf.c
to:

        TIFFGetFieldDefaulted(input, TIFFTAG_PHOTOMETRIC,
&(t2p->tiff_photometric));

That won't work.

TIFFGetFieldDefaulted is defined in tif_aux.c.  It does not have a case =
for
PhotometricInterpretation, TIFFTAG_PHOTOMETRIC.  That probably means =
that in
the standard document TIFF 6.0 that PhotometricInterpretation field =
presence
is a requirement of Baseline TIFF.  As it is a required field for =
bilevel
TIFF images, there is no standard default.

Perhaps I may suggest to you to write a program using libtiff to check =
for
the presence of the TIFFTAG_PHOTOMETRIC tag in your input images and if
non-existent to add the correct required tag to the image.  You could =
change
the TIFFGetField to TIFFGetFieldDefaulted, and it would do no good =
unless
you added a case in TIFFVGetFieldDefaulted in tif_aux.c to set the value =
to
the correct value for those nonstandard image files while not affecting =
the
standard ones.

Your best solution to keep your software compatible with libtiff, =
because
libtiff should not deem a default PhotometricInterpretation as it is a
required field with no default value, is to have your own program check =
the
input file for all required tags and add your own default values for =
those
that are missing.  You can use TIFFSetField on an image you have loaded =
for
reading, I think, I don't recall.

It seems that neither libtiff nor tiff2pdf are in error in this case, =
and
solving the problem for this case would be nonstandard and encumber
maintenance.

You could change the line in tiff2pdf.c to:

if(TIFFGetField(input, TIFFTAG_PHOTOMETRIC, =
&(t2p->tiff_photometric))=3D=3D0){

	t2p->tiff_photometric =3D 0;  // or maybe 1

}

About the Indexed tag, that's absolutely correct, and also I think there =
are
broken images that set PhotometricInterpretation to RGB, SamplesPerPixel =
to
1, and have a ColorMap.

Now, what would be really great is if you wrote a profile validator that
scanned TIFFs for these missing required fields, for all known profiles, =
and
gave it to libtiff.  That would be a wild beastie.

Ross F.


_______________________________________________
Tiff mailing list
Tiff@remotesensing.org
http://xserve.flids.com/mailman/listinfo/tiff
