Return-Path: <tiff-bounces@remotesensing.org>
Received: from xserve.flids.com (adsl-065-083-169-202.sip.mco.bellsouth.net [65.83.169.202])
        by inmx008.isp.belgacom.be (8.12.11/8.12.11/Skynet-IN-2.32) with ESMTP id j4Q8jWM0015781
        for <joris.at.lebbeke@skynet.be>; Thu, 26 May 2005 10:45:37 +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 034FA25A0E01; Thu, 26 May 2005 04:44:52 -0400 (EDT)
X-Original-To: tiff@remotesensing.org
Delivered-To: tiff@remotesensing.org
Received: from hermes.culture.fr (hermes.culture.fr [143.126.201.210])
	by xserve.flids.com (Postfix) with ESMTP id AB99825A0DDE
	for <tiff@remotesensing.org>; Thu, 26 May 2005 04:44:46 -0400 (EDT)
Received: by mta.culture.fr with id j4Q8ibRO005662
	for <tiff@remotesensing.org>; Thu, 26 May 2005 10:44:37 +0200
Received: from archives.culture.fr (archives.culture.fr) by pasteur.culture.fr
	(Content Technologies SMTPRS 4.3.17) with ESMTP id
	<T7125023e358f7ec9dc3f4@pasteur.culture.fr>; 
	Thu, 26 May 2005 10:43:28 +0200
Received: from PRECISION360 by archives.culture.fr with ESMTP id
	j4Q8ialU005347; Thu, 26 May 2005 10:44:36 +0200
Date: Thu, 26 May 2005 10:37:35 +0200
From: Jean-Yves Le Ridant <jean-yves.leridant@culture.gouv.fr>
X-Mailer: The Bat! (v3.0.1.33) Professional
Organization: =?gb2312?Q?Minist=E8re_de_la_Culture?=
X-Priority: 3 (Normal)
Message-ID: <173782225.20050526103735@culture.gouv.fr>
To: "yourpattern" <yourpattern@126.com>
Subject: Re[2]: [Tiff] How to Write a tif file with compression =
	COMPRESSION_JPEG & photometric = PHOTOMETRIC_YCBCR ?
In-Reply-To: <42952B58.000005.30750@m52.126.com>
References: <42952B58.000005.30750@m52.126.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=gb2312
Cc: tiff <tiff@remotesensing.org>
X-BeenThere: tiff@remotesensing.org
X-Mailman-Version: 2.1.2
Precedence: list
Reply-To: Jean-Yves Le Ridant <jean-yves.leridant@culture.gouv.fr>
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
Content-Transfer-Encoding: 8bit
X-MIME-Autoconverted: from quoted-printable to 8bit by inmx008.isp.belgacom.be id j4Q8jWM0015781
X-UIDL: 000000000023ceae.0000027c
X-MSP-STORE: Thu, 26 May 2005 10:45:46 +0200
Status:   

Hello yourpattern,

Thursday, May 26, 2005, 3:50:17 AM, you wrote:

>>Hi all,
>>I want to write a bitcount = 24bit(or 8bit)  image to a tif file with JPEG compression.
>>I can save it with photometric = PHOTOMETRIC_RGB,but when i save it with PHOTOMETRIC_YCBCR
>>it seems doesn't work, why ?
>>It seems that i should do some operations on the RGB source image before i save it with
>>PHOTOMECTRIC_YCBCR ?

>>>This operations are done by libtiff if you uncomment
>>>TIFFSetField(m_tif, TIFFTAG_JPEGCOLORMODE, JPEGCOLORMODE_RGB);
>>>in the program you have posted.
>>>
>>>Best would be to have a tiffinfo of tiffdump of the file that
>>>acdsee don't want to open.
>>> Jean-Yves

y> Thanks Jean-Yves,

y> I have already done the things like you said,comment the
y> TIFFSetFiled(m_tif,TIFFTAG_JPEGCOLORMODE,JPEGCOLORMODE_RGB)...,but
y> still doesn't work.

Hum ..., what I said was *un*comment this line.
JPEGCOLORMODE_RGB must be understood from "jpeg compressor point of
view', not exactly standard but a common practice, baseline, ....
of converting RGB to YCC.
In clear, with this flag, RGB is automatically converted to/from YCC.

y> then i use my code to read this pic, 
y> and save it with compression = COMPRESSION_JPEG & photometric = PHOTOMETRIC_YCBCR
y> with tiffdump,i saw follows:(FILE 2)
y> Magic: 0x4949 <little-endian> Version: 0x2a
y> Directory 0: offset 19642 (0x4cba) next 0 (0)
y> ImageWidth (256) SHORT (3) 1<422>
y> ImageLength (257) SHORT (3) 1<158>
y> BitsPerSample (258) SHORT (3) 3<8 8 8>
y> Compression (259) SHORT (3) 1<7>
y> Photometric (262) SHORT (3) 1<6>
y> StripOffsets (273) LONG (4) 1<8>
y> Orientation (274) SHORT (3) 1<1>
y> SamplesPerPixel (277) SHORT (3) 1<3>
y> RowsPerStrip (278) SHORT (3) 1<158>
y> StripByteCounts (279) LONG (4) 1<19633>
y> XResolution (282) RATIONAL (5) 1<96.512>
y> YResolution (283) RATIONAL (5) 1<96.512>
y> PlanarConfig (284) SHORT (3) 1<1>
y> ResolutionUnit (296) SHORT (3) 1<2>
y> 347 (0x15b) UNDEFINED (7) 574<0xff 0xd8 0xff 0xdb 00 0x43 00 0x8 0x6 0x6 0x7 0x6
y>  0x5 0x8 0x7 0x7 0x7 0x9 0x9 0x8 0xa 0xc 0x14 0xd ...>
y> YCbCrSubsampling (530) SHORT (3) 2<1 1>
y> ReferenceBlackWhite (532) RATIONAL (5) 6<0 255 128 255 128 255>

y> After doing some comparing things,i found almost every tag is same.
y> except for the StripBytesCounts ,and the file i created has one tag RowsPerStrip which
y> the file ACDSEE created didn't have.
y> but this file(i created) still can't be opened by ACDSEE5.

Seems like if ACDSEE don't want stripped files .... :-(((
This dump is consistant with JPEGCOLORMODE_RAW and PHOTOMETRIC_YCBCR,
if you have set somewhere YCBCRSUBSAMPLING to 1,1.

What I do not understand is why tiffdump "UNDEFINE" à well formed
JPEGTABLE field. ( 2 fields, so there also, consistant with a JCS_YCC).

y> I opened this file(I created,file 2) in LeadTools ,the image color seems changed a lot.
y> so i modify the Photometric tag value from 6 to
y> 2,(PHOTOMETRIC_YCBCR =6,& PHOTOMETRIC_RGB=2),this time the color
y> seemed right.(in Leadtools,ACDSEE can't open it).

Such practice may produce hasardous results, cause of possible
traitements by the a jpeg decompressor of fields infos in the jpeg stream.
When you do this, your file is "basically" incorrect.
If photometric is something else than YCBCR, the infos in jpeg stream
must reflect an "unknown" colorspace.

--
Jean-Yves

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

