Why the various JPEG Extensions?
image, jpeg, mime-types, python
Solution
It appears `mimetypes.guess_extension` returns the first of all possible extensions:
def guess_extension(self, type, strict=True):
# ...
extensions = self.guess_all_extensions(type, strict)
if not extensions:
return None
return extensions[0]
So you'll get whichever is first in the list returned by `mimetypes.guess_all_extensions`, which turns out to be:
>>> mimetypes.guess_all_extensions('image/jpeg', strict=False)
['.jpe', '.jpg', '.jpeg']
My guess as to why `.jpe` is also valid:
In DOS and early Windows versions filenames could only have 8 characters and 3 characters for the extension (see the article 8.3 filename on Wikipedia for more info). It could be that they abbreviated JPEG to .JPE or .jpe - which is why we now have .jpe, .jpeg and .jpg.
It's indeed true that .jpeg and .jpg are more common.
Problem
While working on a downloader, I've encountered the following with Python's `mimetypes.guess_extension` function: ``` In [2]: mimetypes.guess_extension('image/jpeg', strict=False) Out[2]: '.jpe' ``` I knew that jpeg and jpg are valid JPEG extensions, but I didn't know about jpe. So looking at the wikipedia site did reveal the following: The most common filename extensions for files employing JPEG compression are .jpg and .jpeg, though .jpe, .jfif and .jif are also used Even more extensions I didn't know of. So the main question: Why does JPEG have so many (valid) extensions associated with it? On a related note I'd like to know why Python does return 'jpe' and not 'jpg' or 'jpeg' since I see these used the most.