2008.02.18 10:44 "RE: [Tiff] bug? JPEGQUALITY seems not to be read correctly", by Gerben Vos
In my own JPEG code (non-LibTIFF) have had good success faking a q-setting by looking at one certain value in the table.
Some rather sophisticated code is available on the Internet to reconstruct the quality value from the tables in a JPEG. It is claimed to work quite well for libjpeg-generated JPEGs. In my experience it can be off with JPEGs from other sources; I imposed a minimum value of 25 on it to prevent it from getting too low.
See "JPEG Compression Metric as a Quality Aware Image Transcoding", Surendar Chandra and Carla Schlatter Ellis. In Second Usenix Symposium on Internet Technologies and Systems (USITS '99), Oct 12, 1999. http://www.cse.nd.edu/~surendar/publications.shtml#usits99
Code at http://www.cse.nd.edu/~csesys/qat/source/.