From 19e1d132c242e0b552424d079d3cdfbcec64e026 Mon Sep 17 00:00:00 2001 From: Raphael Michel Date: Fri, 21 Jul 2023 12:17:36 +0200 Subject: [PATCH] Fix image being used twice on badge (#3486) --- src/pretix/base/pdf.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/pretix/base/pdf.py b/src/pretix/base/pdf.py index 96241cb0a..2b6a51f3b 100644 --- a/src/pretix/base/pdf.py +++ b/src/pretix/base/pdf.py @@ -54,6 +54,7 @@ from django.conf import settings from django.contrib.staticfiles import finders from django.core.exceptions import ValidationError from django.db.models import Max, Min +from django.db.models.fields.files import FieldFile from django.dispatch import receiver from django.utils.deconstruct import deconstructible from django.utils.formats import date_format @@ -878,6 +879,11 @@ class Renderer: anchor='c', # centered in frame mask='auto' ) + if isinstance(image_file, FieldFile): + # ThumbnailingImageReader "closes" the file, so it's no use to use the same file pointer + # in case we need it again. For FieldFile, fortunately, there is an easy way to make the file + # refresh itself when it is used next. + del image_file.file except: logger.exception("Can not load or resize image") canvas.saveState()