Firefox has a feature that I’d like to use in my add-on, but I don’t know how.
Description of the feature:
Suppose you want to download an image that has the wrong file extension, like this one: http://www.furaffinity.net/view/18473875/
(safe for work)
The file extension is .png, but the image is actually a JPG.
When you right-click the image and select “Save Image As”, Firefox automatically adds .jpeg to the file name, so that it becomes:
1449785049.badsheep_taocowwinterbg.png.jpeg
Firefox has some fairly sophisticated image sniffing internally. It is not exposed to javascript, so I don’t think you can use it. Your best bet might be to write your own, or copy it. It is trivial to detect the three or four most common image formats.