Replace 'None' conversion type with "PyMuPDF"

Replaced for clarity over the fact that this conversion is in fact
handled by PyMuPDF.
This commit is contained in:
deeplow 2024-01-29 16:36:16 +00:00
parent 3e10fd1df4
commit 4e720aa6e2
No known key found for this signature in database
GPG key ID: 577982871529A52A

View file

@ -47,7 +47,7 @@ class DocumentToPixels(DangerzoneConverter):
async def convert(self) -> None: async def convert(self) -> None:
conversions: Dict[str, Dict[str, Optional[str]]] = { conversions: Dict[str, Dict[str, Optional[str]]] = {
# .pdf # .pdf
"application/pdf": {"type": None}, "application/pdf": {"type": "PyMuPDF"},
# .docx # .docx
"application/vnd.openxmlformats-officedocument.wordprocessingml.document": { "application/vnd.openxmlformats-officedocument.wordprocessingml.document": {
"type": "libreoffice", "type": "libreoffice",
@ -146,14 +146,14 @@ class DocumentToPixels(DangerzoneConverter):
"type": "libreoffice", "type": "libreoffice",
}, },
# .jpg # .jpg
"image/jpeg": {"type": None}, "image/jpeg": {"type": "PyMuPDF"},
# .gif # .gif
"image/gif": {"type": None}, "image/gif": {"type": "PyMuPDF"},
# .png # .png
"image/png": {"type": None}, "image/png": {"type": "PyMuPDF"},
# .tif # .tif
"image/tiff": {"type": None}, "image/tiff": {"type": "PyMuPDF"},
"image/x-tiff": {"type": None}, "image/x-tiff": {"type": "PyMuPDF"},
} }
# Detect MIME type # Detect MIME type
@ -173,7 +173,7 @@ class DocumentToPixels(DangerzoneConverter):
# Convert input document to PDF # Convert input document to PDF
conversion = conversions[mime_type] conversion = conversions[mime_type]
if conversion["type"] is None: if conversion["type"] == "PyMuPDF":
try: try:
doc = fitz.open("/tmp/input_file", filetype=mime_type) doc = fitz.open("/tmp/input_file", filetype=mime_type)
except (ValueError, fitz.FileDataError): except (ValueError, fitz.FileDataError):