Commit 6a085c21 authored by Luna's avatar Luna 📟

images: hardcode jpeg/webp

parent 3e28501b
Pipeline #37309322 passed with stage
in 6 minutes and 1 second
......@@ -14,17 +14,30 @@ IMAGE_FOLDER = Path('./images')
log = Logger(__name__)
def _get_ext(mime: str):
if mime == 'image/webp':
return 'webp'
EXTENSIONS = {
'image/jpeg': 'jpeg',
'image/webp': 'webp'
}
MIMES = {
'jpg': 'image/jpeg',
'jpe': 'image/jpeg',
'webp': 'image/webp',
}
def _get_ext(mime: str) -> str:
if mime in EXTENSIONS:
return EXTENSIONS[mime]
extensions = mimetypes.guess_all_extensions(mime)
return extensions[0].strip('.')
def _get_mime(ext: str):
if ext == 'webp':
return 'image/webp'
if ext in MIMES:
return MIMES[ext]
return mimetypes.types_map[f'.{ext}']
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment