【发布时间】:2014-03-23 00:28:29
【问题描述】:
我想制作用户上传的 pdf 或 ppt 的缩略图 我试过了
$file = 'Digital Signage.pptx';
$cache = $_SERVER['DOCUMENT_ROOT'].'/cache/';
$ext = "jpg";//just the extension
$dest = $cache.$file.'.'.$ext;
if (file_exists($dest)){
$img = new imagick();
$img->readImage($dest);
header( "Content-Type: image/jpg" );
echo $img;
exit;
} else {
$img = new imagick($_SERVER['DOCUMENT_ROOT'].'/'.$file.'[0]');
$img->setImageFormat($ext);
$width = $img->getImageheight();
//$img->cropImage($width, $width, 0, 0);
$img->scaleImage(105, 149, true);
$img->writeImage($dest);
header( "Content-Type: image/jpg" );
echo $img;
exit;
}
但是这需要在服务器上安装 imagic 并且我的主机不允许我,因为我在共享主机上是否有任何其他方法可以做到这一点
我也可以使用 exec 命令,因为它不安全,我一定不会使用它
【问题讨论】:
-
这里需要在哪里转义单引号?
-
抱歉标题不正确
标签: php pdf thumbnails powerpoint imagick