AWARE SYSTEMS
TIFF and LibTiff Mail List Archive

Thread

2005.05.25 09:52 "[Tiff] How to Write a tif file with compression = COMPRESSION_JPEG & photometric = PHOTOMETRIC_YCBCR ?", by yourpattern
2005.05.25 10:41 "Re: [Tiff] How to Write a tif file with compression = COMPRESSION_JPEG & photometric = PHOTOMETRIC_YCBCR ?", by Jean-Yves Le Ridant
2005.05.26 01:50 "Re: [Tiff] How to Write a tif file with c ompression = COMPRESSION_JPEG & photometr ic = PHOTOMETRIC_YCBCR ?", by yourpattern
2005.05.26 08:37 "Re[2]: [Tiff] How to Write a tif file with compression = COMPRESSION_JPEG & photometric = PHOTOMETRIC_YCBCR ?", by Jean-Yves Le Ridant

2005.05.26 08:37 "Re[2]: [Tiff] How to Write a tif file with compression = COMPRESSION_JPEG & photometric = PHOTOMETRIC_YCBCR ?", by Jean-Yves Le Ridant

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

Thanks Jean-Yves,

I have already done the things like you said,comment the TIFFSetFiled(m_tif,TIFFTAG_JPEGCOLORMODE,JPEGCOLORMODE_RGB)...,but 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.

then i use my code to read this pic,
and save it with compression = COMPRESSION_JPEG & photometric = PHOTOMETRIC_YCBCR
with tiffdump,i saw follows:(FILE 2)

Magic: 0x4949 <little-endian> Version: 0x2a
Directory 0: offset 19642 (0x4cba) next 0 (0)
ImageWidth (256) SHORT (3) 1<422>
ImageLength (257) SHORT (3) 1<158>
BitsPerSample (258) SHORT (3) 3<8 8 8>
Compression (259) SHORT (3) 1<7>
Photometric (262) SHORT (3) 1<6>
StripOffsets (273) LONG (4) 1<8>
Orientation (274) SHORT (3) 1<1>
SamplesPerPixel (277) SHORT (3) 1<3>
RowsPerStrip (278) SHORT (3) 1<158>
StripByteCounts (279) LONG (4) 1<19633>

XResolution (282) RATIONAL (5) 1<96.512>
YResolution (283) RATIONAL (5) 1<96.512>

PlanarConfig (284) SHORT (3) 1<1>
ResolutionUnit (296) SHORT (3) 1<2>

347 (0x15b) UNDEFINED (7) 574<0xff 0xd8 0xff 0xdb 00 0x43 00 0x8 0x6 0x6 0x7 0x6
 0x5 0x8 0x7 0x7 0x7 0x9 0x9 0x8 0xa 0xc 0x14 0xd ...>

YCbCrSubsampling (530) SHORT (3) 2<1 1>
ReferenceBlackWhite (532) RATIONAL (5) 6<0 255 128 255 128 255>

After doing some comparing things,i found almost every tag is same.

except for the StripBytesCounts ,and the file i created has one tag RowsPerStrip which

the file ACDSEE created didn't have.

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