Why sharp and Pillow produce different JPEG file sizes at the same quality

Two image libraries, sharp and Pillow, produce different JPEG byte counts at the same quality setting mainly because of default encoder options. The main difference is Huffman table optimisation, which sharp enables by default and Pillow leaves off unless told otherwise. Testing a 1920-pixel photo at quality 80, Pillow wrote 190.3 KB and sharp 185.3 KB, and with optimisation turned on in Pillow the compressed data matched almost exactly. A larger gap appears when sharp's mozjpeg option is used, since it changes the quantisation tables and cuts file size by roughly 17 to 21 percent. Pillow's default quality of 75 also differs from sharp's default of 80, so calls that omit the quality setting are not directly comparable.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.


Discussion (0)
Log in to join the discussion and vote.
Log in