News websites are increasingly using high-resolution images on their sites and this is causing calibre downloads to become very large. I have experimented with re-dimensioning images to fit inside device screen resolution and increasing jpeg compression to reduce the total download size.
Re-dimensioning and then compressing images by progressively reducing the quality setting until the image size falls below a threshold has a dramatic effect on download size--reductions of 60% are typical. There is generally no perceptible reduction in image quality. The threshold I used is (w*h)/16 bytes where w x h are the image dimensions in pixels.
I have made the modifications required to support re-dimensioning and image compression in news.py and simple.py and these files are attached (based on the most recent calibre release). I'm hoping these changes will be incorporated. The compression will work for all output formats (MOBI, EPUB, etc.)
The following five parameters have been added to BasicNewsRecipe, so they can be overridden as desired in custom recipes. My recommendation is to have compress_news_images default to True so all existing recipes will benfit from image compression without requiring modification.
Code:
'''
The following parameters control how the recipe attempts to minimize image sizes
'''
compress_news_images = True
'''
Set this to False to ignore all scaling and compression parameters and
pass images through unmodified. If True and the other compression
parameters are left at their default values, images will be scaled to fit
in the screen dimensions set by the output profile and compressed to size at
most (w * h)/16 where w x h are the scaled image dimensions.
'''
compress_news_images_auto_size = 16
'''
The factor used when auto compressing jpeg images. If set to None,
auto compression is disabled. Otherwise, the images will be reduced in size to
(w * h)/compress_news_images_auto_size bytes if possible by reducing
the quality level, where w x h are the image dimensions in pixels.
The minimum jpeg quality will be 5/100 so it is possible this constraint
will not be met. This parameter can be overridden by the parameter
compress_news_images_max_size which provides a fixed maximum size for images.
'''
compress_news_images_max_size = None
'''
Set jpeg quality so images do not exceed the size given (in KBytes).
If set, this parameter overrides auto compression via compress_news_images_auto_size.
The minimum jpeg quality will be 5/100 so it is possible this constraint
will not be met.
'''
scale_news_images_to_device = True
'''
Rescale images to fit in the device screen dimensions set by the output profile.
Ignored if no output profile is set.
'''
scale_news_images = None
'''
Maximum dimensions (w,h) to scale images to. If scale_news_images_to_device is True
this is set to the device screen dimensions set by the output profile unless
there is no profile set, in which case it is left at whatever value it has been
assigned (default None).
'''
The modified code is as follows in the attached files:
simple.py lines 145-150, 347-385 and 432-461
news.py lines 413-459 and 900-913