Open inkhey opened 4 years ago
Note: it's possible to add manually new type to default mimetype list, using a specific mimetype datastore, this allow us to easily guess_extension and/or mimetype from both extension/mimetype:
>>>mimetypes_data = mimetypes.MimeTypes()
>>>mimetypes_data.add_type('image/x-sony-arw', 'arw')
>>>mimetypes_data.guess_extension('image/x-sony-arw')
'arw'
This may be useful in builder, if we need to obtain extension related to a file with mimetype known but without file_extension in path (currently we do not have "file_extension" parameter in builder, only file_path which need to exist). this can allow to have specific behavior for builder who really need explicit mimetype. For example with imagemagick builder, we can do, if we get 'arw from mimetype 'image/x-sony-arw' :
convert arw:DSC08523 -layers merge test.jpg
Mimetype guessing is complex, i do suggest to add a "mimetype guesser" class usable outside of preview-generator code (another project ?).
I do suggest to add support for two mimetype guesser:
Original issue text: