Improve quality of Wand conversion
Asked Answered
E

1

20

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?

Estimate answered 26/6, 2013 at 7:47 Comment(0)
A
36

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')
Aeromedical answered 26/6, 2013 at 8:7 Comment(2)
I am using wand to resize the image to decrease its size, but I keep getting images with bigger sizes sometimes with a lot bigger sizes. How to fix this?Cyanogen
For posterity, the default resolution is 72. Units are pixels per inch. The result is not aliased, so the choice is between huge files or pixelated curves.Nikos

© 2022 - 2024 — McMap. All rights reserved.