PDF to PNG conversion with good quality.

IMagick is a native PHP extension to create and modify images using the ImageMagick API. ImageMagick Studio LLC did not write nor does it maintain the IMagick extension, however, IMagick users are welcome to discuss the extension here.
Post Reply
h2shin
Posts: 7
Joined: 2012-09-03T10:28:44-07:00
Authentication code: 67789

PDF to PNG conversion with good quality.

Post by h2shin »

I've been searching around for a while and still can't find a way to use imagick to convert a pdf file to a png file with good original quality.

I'm in need of converting pdf documents containing text as well as images to png files, in such a way that image/text is sharp and clear. Is there a way to do this within imagick?

All my attempts so far have been less than fruitful.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: PDF to PNG conversion with good quality.

Post by fmw42 »

Use supersampling technique. Increase the density, then resize by the inverse of the density increase.

convert -density 288 image.pdf -resize 25% output.png

normal density is 72. So 72*4=288. Thus resize is 1/4=25%
h2shin
Posts: 7
Joined: 2012-09-03T10:28:44-07:00
Authentication code: 67789

Re: PDF to PNG conversion with good quality.

Post by h2shin »

But what about with the imagick extension? I really don't know how to work my way around that extension...
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: PDF to PNG conversion with good quality.

Post by fmw42 »

h2shin wrote:But what about with the imagick extension? I really don't know how to work my way around that extension...

Sorry you will need to find the equivalent operations in Imagick. I am not an expert on Imagick. But see http://php.net/manual/en/book.imagick.php and resizeImage() and setImageResolution()
Post Reply