2008.01.23 17:40 "[Tiff] tiff library and exif", by Jamie L. Finch

2008.02.18 12:29 "Re: [Tiff] bug? JPEGQUALITY seems not to be read correctly", by John

On 18/02/2008, Gerben Vos <Gerben@zylab.com> wrote:

Some rather sophisticated code is available on the Internet to reconstruct the quality value from the tables in a JPEG.

Another approach might be to make TIFFTAG_JPEGQUALITY into a real tag. This could be a simpler solution, and almost as good.

I noticed that TTN2 (the revised JPEG-in-tiff note) obsoleted tags 512 -- 521. Perhaps one of these could be reused? RESTART interval, perhaps (it's a TIFF_SHORT):

#define TIFFTAG_JPEGRESTARTINTERVAL     515     /* !restart interval length */

So the procedure on new-style jpeg load and save might be:

save --
  note the value of TIFFTAG_JPEGQUALITY in tag 515
load --
  if present (and in the range 25 - 100, perhaps), use tag 515 to set the
  default value for TIFFTAG_JPEGQUALITY

Old-style jpeg-in-tiff would be unaltered. Of course Q settings are not transferrable between jpeg implementations, but it sounds like the Q guessers are not exact either. It seems to me that saving the Q setting as a hint would not be any worse in practice than adding a Q guesser and would be far simpler (just a few lines of code).

On the downside of course having tags that change meaning depending on context is very, very ugly :-(

The same pseudo-tag problem will affect other compressors I suppose, though JPEG is perhaps the most extreme one (huge changes in filesize with different values).

John