Can I Use Different Quality Levels for JPEG MCUs?

August 9, 2025 3 answers
Asked by !450 charcoal sketches
Hey everyone! I've been diving into JPEG compression for a program I'm developing, and I've come across some intriguing libraries, like TooJPEG. While working with JPEGs, I understand that quantization tables are essential for proper decompressionโ€”usually one for the luminance and another for the chroma channels. My question is, can a single JPEG file hold multiple quantization tables so that different Minimum Coding Units (MCUs) get compressed at different quality levels? For example, I'd like to compress text in a higher quality than photos in the same image. Of course, I'd create a mapping to specify compression levels for each 8x8 block. Is this possible?

Answers

pH8_buffer
You can only utilize one quantization matrix at a time. However, if you adapt the quantization locallyโ€”like rounding to coarser valuesโ€”you might be able to increase compression via Huffman coding. Itโ€™s not a standard approach, though.
Reply to this answer
still~in~training
Unfortunately, that's not feasible. According to the JPEG specification, quantization is strictly determined by the tables in the JPEG frame header. While you can specify separate tables for different color components, there's no way to define which table to use for individual coding units. So, youโ€™d have to stick with one quantization table for the entire image if you want to maintain JPEG standards. You could always create a custom format, but it wouldnโ€™t technically be JPEG anymore.
Reply to this answer
distant thunder~
Nope, the file header dictates the format, and anything beyond that would require a specific decoder to handle it. Youโ€™d need to redesign the compression algorithm to manage varying qualities.
Reply to this answer

Add your answer

Answers are reviewed before publication.

Related Discussions