mirror of
https://github.com/freedomofpress/dangerzone.git
synced 2025-04-28 18:02:38 +02:00
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:
parent
3e10fd1df4
commit
4e720aa6e2
1 changed files with 7 additions and 7 deletions
|
@ -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):
|
||||||
|
|
Loading…
Reference in a new issue