我正在使用Python Wand模块(版本0.4.3。)将存储在pdf中的图像转换为PNG。当我将最终图像保存在原始图像的宽度和高度时,最终的PNG质量非常好。但是,当我尝试将它保存为较小的图像时,最终的PNG会变得模糊,质量也不是那么好。Python Wand Scaling问题
两张图片之间的差异显示为here。顶部图像被转换为原始大小(10800x7200px)。第二个是缩放到1250x833px。
有什么办法可以改善第二张图片吗?我玩过不同的滤镜和模糊设置。但是,无法获得我想要的图像质量。任何帮助是极大的赞赏。
代码我用PDF转换为原始大小巴布亚新几内亚:
def pdf_to_png(pdf_name, res):
with Image(filename=pdf_name, resolution=res) as img:
with Image(width=img.width,height=img.height, background=Color("white")) as bg:
bg.composite(img,0,0)`
bg.save(filename="Drawing_improved_wand.png")`
pdf_to_png('Drawing_1.pdf', 300)
代码调整大小PNG:
with Image(filename="Drawing_1.pdf", resolution=(300,300)) as img:
with Image(width=1250, height=833, background=Color("white")) as bg:
img.resize(1250, 833,filter='undefined', blur=1)
img.format = 'png'
bg.composite(img,0,0)
bg.save(filename='Drawing_improved_wand1250x833.png')
这并不提供答案的问题。一旦你有足够的[声誉](https://stackoverflow.com/help/whats-reputation),你将可以[对任何帖子发表评论](https://stackoverflow.com/help/privileges/comment);相反,[提供不需要提问者澄清的答案](https://meta.stackexchange.com/questions/214173/why-do-i-need-50-reputation-to-comment-what-can- I-DO-代替)。 - [来自评论](/ review/low-quality-posts/16921018) – whrrgarbl