2005.05.26 08:58 "Re: [Tiff] How to Write a tif file with c ompression = COMPRESSION_JPEG & photometr ic = PHOTOMETRIC_YCBCR ?", by Kelvin Zhong

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

This time i scrathed some codes from rgb2ycbcr.c which is distributed with libtiff/tools.It works, and i successfully created the tif image file with compression = COMPRESSION_JPEG & photometric = PHOTOMETRIC_YCBCR, and can be opened by ACDSEE.

Produce a one strip, YCBCR, whatever downsampled image, and tiffcp, tiffdump, or tiffinfo it...


With libtiff 3.7.2...

But i still have some thoughts about this things:

Jean Yves:

you said that libtiff already can do this thing(save the tif image file with compression = COMPRESSION_JPEG & photometric = PHOTOMETRIC_YCBCR ), I tried,but failed. Do you have done such things before? if so,tell me what's wrong in my codes,or tell me how to do? thanks.

Concerning *pseudo-tag* JPEGCOLORMODE_RGB, I used and use it, and it worked and work fine.

What I can imagine, from what I see in code, may be problems relying to order in which you set fields as PLANARCONFIG, PHOTOMETRIC, JPEGCOLORMODE, COMPRESSION...

[ and i looked at manual page of TIFFWriteScanLine()...,it is said,there is a bug related to this:

"Writing subsampled YCbCR data does not work correctly because, for PlanarConfiguration=2 the size of a scanline is not calculated on a per-sample basis, and for PlanarConfiguration=1 the library does not pack the block-interleaved samples."

Seen this after asked some stupid questions there or/and at bugzilla. Notion of scanline for vertically subsampled data is somewhat hazardous. And that tif_jpeg use it for subsampled data... ;-(

so i shift to use TIFFWriteEncodedStrip....,(there is no bug reports in manual page about this function),but it still can't work.).

Strip and tile fonctions, in turn call TIFFVxxxSize fonctions, which give correct result regarding downsampling.

So defining scanlinesize as Stripsize(v_sampling) may have some consistance.

Best is processing subsampling by stripe and tile.