Sameer Zinzuwadia
Sameer Zinzuwadia

Reputation: 3285

Pdf to image using php-imagick api

i want to convert the PDF to image.But when the out put image generate it's get blur from original.Here is code

$uploadfile = ".pdf[53]";
$img = new Imagick($uploadfile);
$img->setResolution(300,300);
$img->resampleImage(150,150,imagick::FILTER_UNDEFINED,1);
$img->resizeImage(512,700,Imagick::FILTER_LANCZOS,0);
$img->setImageFormat('jpeg');
$img->setImageUnits(imagick::RESOLUTION_PIXELSPERINCH);
$img->writeImage ( "p-53.jpeg" );

Can you please help me. Thank you.

Upvotes: 2

Views: 6720

Answers (1)

Lou Franco
Lou Franco

Reputation: 89172

Remove the resample and the resize calls and see what you get. It looks like you are shrinking it and then upsizing it.

edit: setResolution(300,300) is too late -- the image has already been rendered. Do it like this:

$im = new Imagick(); 
$im->setResolution( 300, 300 ); 
$im->readImage( $uploadfile );

Upvotes: 7

Related Questions