From 250e0a930dd2f358a1c47f6ae19a604865c3ad32 Mon Sep 17 00:00:00 2001 From: Raphael Michel Date: Tue, 9 Oct 2018 10:55:56 +0200 Subject: [PATCH] Prevent huge invoice files if a JPEG logo is used --- src/pretix/base/invoice.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/pretix/base/invoice.py b/src/pretix/base/invoice.py index c20b3c120..f9f93fde6 100644 --- a/src/pretix/base/invoice.py +++ b/src/pretix/base/invoice.py @@ -192,8 +192,15 @@ class ThumbnailingImageReader(ImageReader): size=(int(width * dpi / 72), int(height * dpi / 72)), resample=BICUBIC ) + self._data = None return width, height + def _jpeg_fh(self): + # Bypass a reportlab-internal optimization that falls back to the original + # file handle if the file is a JPEG, and therefore does not respect the + # (smaller) size of the modified image. + return None + class ClassicInvoiceRenderer(BaseReportlabInvoiceRenderer): identifier = 'classic'