It seems like decent heuristics for determining the ideal image format should exist.
Here's a theoretical one:
- If multi-frame, -> GIF
- If the alpha channel is actually in use, -> PNG
- No? Why not try to compress a few randomly distributed scanlines with DEFLATE. If the ratio sucks, use JPEG, otherwise use PNG.
Ok, using GIF? We need to decide the color table size, and whether to preserve transparency or support animation. We may consult the original GIF, and look at the operation graph to prove that no new colors were introduced, then re-use that table.
Using PNG? Oh, so many knobs and settings. 8-bit? 24-bit? 32-bit? Size of the color table?
JPEG? What subsampling format? What quality? Should quality decrease with resolution at a certain point (higher res usually means smaller pixels are being displayed)? Should we use trellis?
@pornel, I imagine you've thought about this quite a bit. Other than exhaustive attempts, are you aware of any good techniques for "doing the right thing" by default for the unopinionated user? We would want to budget <50ms for this, preferably <5ms for small images.