Fix #2054125 [ValueError: Failed to export image as JPEG with error: Image is empty](https://bugs.launchpad.net/calibre/+bug/2054125)

This commit is contained in:
Kovid Goyal 2024-02-17 10:10:48 +05:30
parent be8082790a
commit 34743e4807
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -272,7 +272,12 @@ def save_cover_data_to(
changed = True
img = img.scaled(int(resize_to[0]), int(resize_to[1]), Qt.AspectRatioMode.IgnoreAspectRatio, Qt.TransformationMode.SmoothTransformation)
owidth, oheight = img.width(), img.height()
nwidth, nheight = tweaks['maximum_cover_size'] if minify_to is None else minify_to
if minify_to is None:
nwidth, nheight = tweaks['maximum_cover_size']
nwidth, nheight = max(1, nwidth), max(1, nheight)
else:
nwidth, nheight = minify_to
if letterbox:
img = blend_on_canvas(img, nwidth, nheight, bgcolor=letterbox_color)
# Check if we were minified