Pdf使用php-imagick api进行成像 [英] Pdf to image using php-imagick api

查看:100
本文介绍了Pdf使用php-imagick api进行成像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将PDF转换为图像。但是当输出图像生成时,它会从原始模糊。这是代码

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.

推荐答案

删除重新采样和调整大小调用,看看你得到了什么。看起来你正在缩小它然后再升级它。

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

编辑:setResolution(300,300)为时已晚 - 图像已经渲染。这样做:

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

这篇关于Pdf使用php-imagick api进行成像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆