We develop a web application where users upload all kinds of images (photos, technical drawings, comics, line drawings ... everything you can think of). Unfortunately the users do not care about choosing the right file format for the image's content (in fact, they probably do not know that different image formats even exist).
I wonder if there is a way to automatically (without human interaction) detect the best file format (jpeg or png) depending on the image's content. The definition of "best" considers the visual quality in a web context and the file's size.
In other words, this question is similiar to the "Need to preserve finde detail" branch in Google's Image File Format Decision Tree.
This question is not about compressing/optimizing images with tools like pngcrush, pngquant, jpegtran, jpegrescan and others. Those optimizations would be done after choosing the "best" image file format.