Pdf to image using php-imagick api

我们两清 提交于 2019-12-19 09:28:22

问题


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.


回答1:


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 );


来源:https://stackoverflow.com/questions/4211913/pdf-to-image-using-php-imagick-api

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!