相关疑难解决方法(0)

Python Wand将PDF转换为PNG禁用透明(alpha_channel)

我正在尝试将PDF转换为PNG - 这一切都运行正常,但是,即使我相信我已将其禁用,输出图像仍然是透明的:

with Image(filename='sample.pdf', resolution=300) as img:
    img.background_color = Color("white")
    img.alpha_channel = False
    img.save(filename='image.png')
Run Code Online (Sandbox Code Playgroud)

以上产生图像但透明,我也试过以下:

with Image(filename='sample.pdf', resolution=300, background=Color('white')) as img:
    img.alpha_channel = False
    img.save(filename='image.png')
Run Code Online (Sandbox Code Playgroud)

产生此错误:

Traceback (most recent call last):
  File "file_convert.py", line 20, in <module>
    with Image(filename='sample.pdf', resolution=300, background=Color('white')) as img:
  File "/Users/Frank/.virtualenvs/wand/lib/python2.7/site-packages/wand/image.py", line 1943, in __init__
    raise TypeError("blank image parameters can't be used with image "
TypeError: blank image parameters can't be used with image opening parameters
Run Code Online (Sandbox Code Playgroud)

python imagemagick wand

18
推荐指数
3
解决办法
3万
查看次数

标签 统计

imagemagick ×1

python ×1

wand ×1