Browse Source

publish muk_thumbnails - 11.0

pull/19/head
MuK IT GmbH 5 years ago
parent
commit
e8f3fc56c4
  1. 2
      muk_thumbnails/__manifest__.py
  2. 8
      muk_thumbnails/service/thumbnail.py

2
muk_thumbnails/__manifest__.py

@ -20,7 +20,7 @@
{ {
"name": 'MuK Thumbnails', "name": 'MuK Thumbnails',
"summary": """File Thumbnails""", "summary": """File Thumbnails""",
"version": '11.0.1.0.2',
"version": '11.0.1.0.4',
"category": 'Document Management', "category": 'Document Management',
"license": "AGPL-3", "license": "AGPL-3",
"website": "http://www.mukit.at", "website": "http://www.mukit.at",

8
muk_thumbnails/service/thumbnail.py

@ -89,7 +89,7 @@ def formats():
return FORMATS return FORMATS
def imports(): def imports():
return VIDEO_IMPORTS + PDF_IMPORTS + WAND_IMPORTS + unoconv.IMPORTS
return VIDEO_IMPORTS + PDF_IMPORTS + WAND_IMPORTS + unoconv.UNOCONV_IMPORTS
def create_thumbnail(binary, mimetype=None, filename=None, export="binary", format="png", page=0, frame=0, def create_thumbnail(binary, mimetype=None, filename=None, export="binary", format="png", page=0, frame=0,
animation=False, video_resize={'width': 256}, image_resize='256x256>', image_crop=None): animation=False, video_resize={'width': 256}, image_resize='256x256>', image_crop=None):
@ -115,7 +115,7 @@ def create_thumbnail(binary, mimetype=None, filename=None, export="binary", form
raise ValueError("The file extension could not be determined.") raise ValueError("The file extension could not be determined.")
if format not in FORMATS: if format not in FORMATS:
raise ValueError("Invalid export format.") raise ValueError("Invalid export format.")
if extension not in (VIDEO_IMPORTS + PDF_IMPORTS + WAND_IMPORTS + unoconv.IMPORTS):
if extension not in (VIDEO_IMPORTS + PDF_IMPORTS + WAND_IMPORTS + unoconv.UNOCONV_IMPORTS):
raise ValueError("Invalid import format.") raise ValueError("Invalid import format.")
if not imageio or not Image or not VideoFileClip: if not imageio or not Image or not VideoFileClip:
raise ValueError("Some libraries couldn't be imported.") raise ValueError("Some libraries couldn't be imported.")
@ -123,11 +123,11 @@ def create_thumbnail(binary, mimetype=None, filename=None, export="binary", form
image_extension = extension image_extension = extension
if extension in WAND_IMPORTS: if extension in WAND_IMPORTS:
image_data = binary image_data = binary
elif not image_data and (extension in PDF_IMPORTS or extension in unoconv.IMPORTS):
elif not image_data and (extension in PDF_IMPORTS or extension in unoconv.UNOCONV_IMPORTS):
pdf_data = binary if extension in PDF_IMPORTS else None pdf_data = binary if extension in PDF_IMPORTS else None
if not pdf_data: if not pdf_data:
image_extension = "pdf" image_extension = "pdf"
pdf_data = unoconv.convert_binary(binary, mimetype, filename)
pdf_data = unoconv.unoconv.convert(binary, mimetype, filename)
reader = PyPDF2.PdfFileReader(io.BytesIO(pdf_data)) reader = PyPDF2.PdfFileReader(io.BytesIO(pdf_data))
writer = PyPDF2.PdfFileWriter() writer = PyPDF2.PdfFileWriter()
if reader.getNumPages() >= page: if reader.getNumPages() >= page:

Loading…
Cancel
Save