I've got an image that could be a photograph or a screenshot. I want to make sure that the images get saved in an appropriate format. I am talking about jpeg and png at this point.
How can I determine if it would be better to save an image as .jpeg because it is/contains a photo? Also, if the image contains a used alpha channel, png is obviously appropriated.
The simplest way would be to save the image two times with different image formats into a memory stream and compare the corresponding data size. Obviously, this is very resource intensive and - in my opinion - not the way to go.
Anybody got suggestions?
You could look for occurances of continuous runs of the same color, as these are very uncommon in photographs. Of course, with modern UIs, gradient effects are making these less common in screenshots. It's still fairly typical to have solid color areas (grays or whites, in particular), so it's a reasonable heuristic, if you want something quick. You might want to exclude max-intensity white or min-intensity black, as over-exposed or under-exposed photographs can contain large patches of these colors.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With