set Image.MAX_IMAGE_PIXELS=None when using img2pdf

This commit is contained in:
Johannes Schauer Marin Rodrigues 2024-01-12 09:45:20 +01:00
parent fab6925674
commit 2aa1271aec
Signed by: josch
GPG key ID: F2CBA5C78FBD83E1

View file

@ -25,6 +25,11 @@ import logging
have_img2pdf = True
try:
from PIL import Image
# ignore PIL limit because this software is meant to create posters which
# naturally can be very large in size
Image.MAX_IMAGE_PIXELS = None
import img2pdf
except ImportError:
have_img2pdf = False
@ -1353,8 +1358,6 @@ class Application(tkinter.Frame):
)
# remove alpha channel
if remove_alpha:
from PIL import Image
img = Image.open(self.filename).convert("RGBA")
background = Image.new("RGBA", img.size, (255, 255, 255))
img = Image.alpha_composite(background, img)