You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
mimetypes module does not recognize jp2 type #85957
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
assignee=Noneclosed_at=Nonecreated_at=<Date2020-09-15.04:31:47.953>labels= ['type-feature', '3.11']
title='mimetypes module does not recognize jp2 type'updated_at=<Date2022-01-19.00:38:51.433>user='https://github.com/naro'
I've tested with 3.7.8 and got (None, None). I'm curious on how you got that 'image/jp2' output.
It seems jp2 was never supported by looking into the git history of Lib/mimetypes.py.
Would you like to open a PR to support it? :)
naro commented on Sep 18, 2020
naromannequin
MannequinAuthor
More actions
Hi Andrés,
tried again and the difference is between 3.7.4 and 3.7.5
The jp2 mimetype is read from /etc/apache2/mime.types (see knownfiles in mimetypes.py) so the mime type does not have to be in the mimetypes.py hardcoded, but in version 3.7.5 it stopped working.
I think it's because of using _types_map_default instead of types_map in some places.
Since jp2 is an official mime type it should be added to the list but I also think we should try to identify the issue with _types_map_default.
Activity
naro commentedon Sep 15, 2020
Even if jp2 is in the official list of types https://www.iana.org/assignments/media-types/media-types.xhtml it's not recognized by the MimeTypes.guess_type:
The same example works in Python 3.7 and returns 'image/jp2'
andresdelfino commentedon Sep 17, 2020
Hi, Radim!
I've tested with 3.7.8 and got (None, None). I'm curious on how you got that 'image/jp2' output.
It seems jp2 was never supported by looking into the git history of Lib/mimetypes.py.
Would you like to open a PR to support it? :)
naro commentedon Sep 18, 2020
Hi Andrés,
tried again and the difference is between 3.7.4 and 3.7.5
The jp2 mimetype is read from /etc/apache2/mime.types (see knownfiles in mimetypes.py) so the mime type does not have to be in the mimetypes.py hardcoded, but in version 3.7.5 it stopped working.
I think it's because of using _types_map_default instead of types_map in some places.
Since jp2 is an official mime type it should be added to the list but I also think we should try to identify the issue with _types_map_default.
Seems to be related to https://bugs.python.org/issue4963
I will have look if I can find out what was changed and why.
Cheers,
Radim
andresdelfino commentedon Sep 18, 2020
Nice debugging!
iritkatriel commentedon Jan 18, 2022
It is found by the module-level guess_type but not by the MimeType class's guess_type:
That difference is the subject of bpo-38656.
What remains to decide here is whether jp2 should be added to the builtin list of mimetypes.
2 remaining items
fix(lab-2558): manage mimetypes module issue on Windows
fix(lab-2558): manage mimetypes module issue on Windows
fix(lab-2558): manage mimetypes module issue on Windows
fix(lab-2558): manage mimetypes module issue on Windows
fix(lab-2558): manage mimetypes module issue on Windows
fix(lab-2558): manage mimetypes module issue on Windows
hugovk commentedon Nov 18, 2024
Please see PR #126966.
gh-85957: Add missing MIME types for images with RFCs (#126966)
pythongh-85957: Add missing MIME types for images with RFCs (python#1…