Improve quality of Wand conversion

谁说胖子不能爱 提交于 2019-11-27 16:02:17

问题


I convert files of different formats (JPEG, PNG, TIFF, PDF) to JPEG using Wand, a ctypes-based ImageMagick binding for Python. The resulting files are very low-quality. If there is text in original file, it becomes almost unreadable in the resulting file.

Before Wand i used Imagemagick console commands, and with the option -density i could achieve great quality. For example: convert -density 200 file.pdf file.jpg.

What is the most idiomatic way to improve image quality of the resulting image file in Wand? Or, at least, how do i set the density option in Wand?


回答1:


This would help you. Pass resolution option to the constructor of Image e.g.:

with Image(filename='file.pdf', resolution=200) as image:
    image.compression_quality = 99
    image.save(filename='file.jpg')


来源:https://stackoverflow.com/questions/17314382/improve-quality-of-wand-conversion

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!