php - 从 pdf 创建缩略图
问题描述
我必须从 pdf 创建缩略图(以 png 或 jpg 格式)。我找到了 Imagik 库,它需要 GhostScript。两者都安装在主机上,但代码不起作用。我在官方文档中找到了。我在另一个带有图像标题的 php 文件中进行了测试,但没有成功。我是否必须创建一个带有图像标题的其他 php 文件并测试该文件是否已经存在?
<?php
try {
$bdd = new PDO('mysql:host=*db url*;dbname=teg;charset=utf8', *user*, *password*);
}
catch (Exception $e){
die('Erreur : ' . $e->getMessage());
}
$reponse = $bdd->query('SELECT * FROM kiosque ORDER BY date_publication DESC');
while ($kiosque = $reponse->fetch())
{
$im = new Imagick();
$im->setResolution(400, 565);
$im->readImage('/resources/kiosque/'. $kiosque['edition'] . '.pdf[0]');
$im->writeImages('/resources/kiosque/' . $kiosque['edition'] . '.png', false);
?>
<div class="edition">
<img src="/resources/kiosque/<?php echo $kiosque['edition'];?>.png"></img>
<h2>Edition #<?php echo $kiosque['numero']; ?></h2>
<h3 class="date"><?php echo $kiosque['date_publication'];?></h3>
<p><?php echo $kiosque['description'];?></p>
<a class="button" href="lire.php?numero=<?php echo $kiosque['numero'];?>&date=<?php echo $kiosque['date_publication'];?>&edition=<?php echo $kiosque['edition'];?>">Lire cette édition</a>
</div>
<?php
}
$reponse->closeCursor();
?>
解决方案
推荐阅读
- php - 作曲家安装 Symphony 时出错
- apache-beam - Apache calcite:将整数转换为日期时间
- rethinkdb - RethinkDB 查询:如何根据日期范围进行采摘
- jquery - 删除向上箭头并替换为按钮上的向下箭头
- excel - 如何从当前日期减去自动过滤 VBA 的 3 天
- c# - Unity3D中使用第一人称控制器进行空中移动,c#
- regex - 正则表达式将组视为字符串
- sql - 查找连接表中两个 ID 之间的最短路径长度
- javascript - 如何在使用 Javascript 在 div 中附加 html 时实现字符串插值
- angular - Angular App 只允许构造函数中的依赖项使用@Inject