We need an image compression format that supports both lossy and lossless in the same container.
We also need an image compression format that supports multiple levels of lossy compression within the same image.
The image format should support non-complex regions, e.g. this rectangular area, where the compression cab be tweaked to be lossless or lossy and just how lossy it can be before quality degrades.
When reconstructing the image, it is assembled using a painter’s algorithm, whereby the most lossy images are drawn first, then the less lossy images are drawn over those, then the lossless image is drawn over that.
With this technique, text and bitmaps would be sharp, and natural tone images would be acceptable. If an image contains both, then different algorithms can be used to compress the different regions.
A reasonably simple image analysis and detection algorithm should be able to figure out whether something is likely to be a continuous tone image or a bitmap image, and then select the appropriate compression algorithm.
Some user control, either by specifying regions, or adjusting slider controls would permit controlling the aggressiveness of the lossy compression algorithms.