Fix #1531 (white background on transparent cover instead of black one)

This commit is contained in:
Ozzie Isaacs 2020-07-23 18:41:38 +02:00
parent 25fc6f1937
commit e27b08203d

View File

@ -35,7 +35,7 @@ except ImportError:
lxmlversion = None lxmlversion = None
try: try:
from wand.image import Image from wand.image import Image, Color
from wand import version as ImageVersion from wand import version as ImageVersion
from wand.exceptions import PolicyError from wand.exceptions import PolicyError
use_generic_pdf_cover = False use_generic_pdf_cover = False
@ -149,6 +149,9 @@ def pdf_preview(tmp_file_path, tmp_dir):
img.options["pdf:use-cropbox"] = "true" img.options["pdf:use-cropbox"] = "true"
img.read(filename=tmp_file_path + '[0]', resolution=150) img.read(filename=tmp_file_path + '[0]', resolution=150)
img.compression_quality = 88 img.compression_quality = 88
if img.alpha_channel:
img.alpha_channel = 'remove'
img.background_color = Color('white')
img.save(filename=os.path.join(tmp_dir, cover_file_name)) img.save(filename=os.path.join(tmp_dir, cover_file_name))
return cover_file_name return cover_file_name
except PolicyError as ex: except PolicyError as ex: