Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Improve quality of Wand conversion

Tags:

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?

like image 501
Mirzhan Irkegulov Avatar asked Jun 26 '13 07:06

Mirzhan Irkegulov


1 Answers

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') 
like image 109
minhee Avatar answered Oct 15 '22 02:10

minhee