Thread: Compress images
View Single Post
Old 04-08-2024, 02:42 PM   #15
peekpoke
Enthusiast
peekpoke began at the beginning.
 
Posts: 41
Karma: 10
Join Date: Dec 2013
Device: Kindle/Android
Quote:
Originally Posted by theducks View Post
It is easy.
Use the polish tool (compress is one of the options)from the main toolbar (you may need to add the icon. Preferences : toolbars
Unfortunately the Polish tool doesn't allow lossy compression.
It's hardcoded into the source code to NEVER reduce the quality.
calibre/src/calibre/ebooks/oeb/polish/images.py

The code says either losslessly re-encode (using optimize_jpeg), or recompress using the same quality (using encode_jpeg).

elif self.jpeg_quality is None:
func = optimize_jpeg
else:
func = partial(encode_jpeg, quality=self.jpeg_quality)

To force it to use Quality 50, I made this change in my local source, removing elif self.jpeg_quality part.

else:
func = partial(encode_jpeg, quality=50)

After that change it appears to reduce using polish. Got a drastic reduction in file size. Unfortunately you cannot specity which format to polish, so if perhaps you want to reduce all the AZW3 for kindle, but want to keep original EPUB, it's a hassle of restoring the EPUBs.
peekpoke is offline   Reply With Quote