Page 1 of 1

Convert PDF to PNG without quality in PHP

Posted: 2012-05-11T07:15:51-07:00
by jota_sp_84
Hello people,

I need a help.
I'm using CentOS 6.4 with ImageMagick 6.5.4-7 Q16 and image module 2.2.2 with php 5.3.3 with Ghostscript 8.70-11.e16_2.6.

What is happening is the following. I want to convert a page of the PDF to PNG, only to be coming with bad quality! How can I fix this problem to come with perfect quality?

The code is:

<?
$im = new Imagick ();

$im->readImage ( 'file.pdf[0]' );

$im->setImageFormat('png');

header("Content-type: image/png");

echo $im;

?>

Image

Re: Convert PDF to PNG without quality in PHP

Posted: 2012-05-11T09:14:56-07:00
by fmw42
In command line mode, you would use "supersampling". That is set the density high before reading the image and then resize back down by the same factor. For example

convert -density 288 image.pdf[0] -resize 25% image.png

normal density is 72 dpi. so 4*72=288. Thus you must resize by 1/4=25%

Sorry I don't know the equivalent in Imagick.

Re: Convert PDF to PNG without quality in PHP

Posted: 2012-11-12T08:50:32-07:00
by isswal
Hi,
can you tell me is that you settle your problem, because I have the same concern that I convert a pdf image but unfortunately the image is not good quality.

thank you very much

Re: Convert PDF to PNG without quality in PHP

Posted: 2013-01-21T20:10:05-07:00
by mkoppanen