2007.02.05 03:28 "[Tiff] Request help On OJPEG Compression In Libtiff", by Steven Lim

2007.02.06 04:04 "Re: [Tiff] What's wrong with this program about adding a bitmap to TIFF file as Compression_JPEG ?", by Joris Van Damme

Unknown name in non-ascii chars,

Unknown name in non-ascii chars wrote:

procedure AddBitmapAsJpegtoTiff;

On the whole, your code looks reasonable, except for the following:


Whilst the combination of JPEG compression and RGB photometric is perfectly legit on the TIFF level, it is badly supported. LibTiff may or may not be able to write it flawlessly (I suspect it will at least incorrectly add subsampling tags, but that shouldn't be too much of a problem), but very few readers are able to deal with it.


Of course, next you have to actually convert the color data to actual YCbCr before your call to TIFFWriteEncodedStrip.

This code also has a problem, RowsPerStrip:=((256*1024) div (Bitmap.Width*3));if 256*1024 become a large number,there will be more than one strip in the IFD,but the data can't write ,only 1 KB after writing tothe TIFF.

Huh? 256*1024 is a constant, cannot 'become a large number', and I've never met data that can write - it's usually the code that does the writing.

This part of the code is fine. The rationale is, we aim at strips of about a quarter of a megabyte big, in their uncompressed form. So to approximate that, we make the div to find out how many lines make up that quarter of a megabyte. Next, we check and see if the result is either more then the image height, or less then 1, in either case we fix it up.

How to add two bitmaps to one TIFF ,also as Compression_JPEG?

That is documented on the LibTiff site.

If I remember correctly, you do need to make sure you've the latest version of LibTiffDelphi, as in some earlier versions I forgot to declare one function you need for this.

Best regards,

Joris Van Damme
Download your free TIFF tag viewer for windows here: