繁体   English   中英

使用wand.image + python 2.7修剪空白

[英]Using wand.image + python 2.7 to trim white space

是否可以使用wand.image修剪PDF生成的jpg周围的白色边框,还是我应该使用其他软件包? 请注意,jpg是带有@边框的不同颜色的图像。 下面的代码为每个零件生成图像文件。 只是不知道如何修剪空白

from wand.image import Image
f = "my_pdf.pdf"
with Image(file=f, resolution=72) as document:
    for page_number, page in enumerate(document.sequence):
        with Image(page) as img:
            img.compression_quality = 70
            bytes_io_file = BytesIO(img.make_blob('JPEG'))

我的系统:Ubuntu 16上的python 2.7

先感谢您!

应该有一个Image.trim方法来执行此操作。

>>> from wand.image import Image
>>> from wand.color import Color
>>> with Image(filename="logo:") as img:
...   img.trim(Color("WHITE"))
...   img.save(filename="output.png")

output.png

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM