add .tiff as supported image format

This commit is contained in:
j 2025-01-31 10:40:04 +05:30
commit 017d9be45a
3 changed files with 26 additions and 12 deletions

View file

@ -1,8 +1,9 @@
# -*- coding: utf-8 -*-
from glob import glob
import mimetypes
import os
import re
from glob import glob
import unicodedata
import ox
@ -379,11 +380,13 @@ actions.register(sortDocuments, cache=False)
def file(request, id, name=None):
document = get_document_or_404_json(request, id)
accept = request.headers.get("Accept")
mime_type = mimetypes.guess_type(document.file.path)[0]
mime_type = 'image/%s' % document.extension
if accept and 'image/' in accept and document.extension in (
'webp', 'heif', 'heic', 'avif'
) and document.extension not in accept:
'webp', 'heif', 'heic', 'avif', 'tiff'
) and mime_type not in accept:
image_size = max(document.width, document.height)
return HttpFileResponse(document.thumbnail(image_size))
return HttpFileResponse(document.thumbnail(image_size, accept=accept))
return HttpFileResponse(document.file.path)
def thumbnail(request, id, size=256, page=None):