Commit 28451c99 authored by Anton Akhmerov's avatar Anton Akhmerov
Browse files

Merge branch '535-pikepdf-decode-img-error' into 'master'

Unexpected error while uploading pdf file

Closes #535

See merge request zesje/zesje!325
parents 68af6d43 023c6c78
......@@ -8,6 +8,7 @@ import re
from flask import current_app
from PIL import Image
from pikepdf import Pdf, PdfImage, PdfError
from pikepdf.models.image import UnsupportedImageTypeError
from tempfile import SpooledTemporaryFile
from wand.image import Color, Image as WandImage
from reportlab.lib.units import inch
......@@ -217,8 +218,9 @@ def extract_images_from_pdf(file_path_or_buffer, file_info=None, dpi=300, only_i
# Try to use PikePDF, but catch any error it raises
img = extract_image_pikepdf(page)
except (ValueError, AttributeError, NotImplementedError, PdfError):
except (ValueError, AttributeError, NotImplementedError, UnsupportedImageTypeError, PdfError):
# Fallback to Wand if extracting with PikePDF failed
# UnsupportedImageTypeError is raised when /CCITTFaxDecode with /EncodedByteAlign true (535)
use_wand = True
if use_wand:
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