下面的代码就像一个魅力:
<?php
$im = new imagick('file.pdf[0]');
$im->setImageFormat( "jpg" );
header( "Content-Type: image/jpeg" );
echo $im;
?>
但是如果我需要在现有的 html 页面中包含该图像怎么办?如果我删除标题图像/jpeg,它将图像显示为文本。我正在寻找一种可以解决问题的 ImageMagick 方法。有什么建议吗?
下面的代码就像一个魅力:
<?php
$im = new imagick('file.pdf[0]');
$im->setImageFormat( "jpg" );
header( "Content-Type: image/jpeg" );
echo $im;
?>
但是如果我需要在现有的 html 页面中包含该图像怎么办?如果我删除标题图像/jpeg,它将图像显示为文本。我正在寻找一种可以解决问题的 ImageMagick 方法。有什么建议吗?
您将在名为 image.php 的单独页面上拥有上面的代码(请注意,您需要删除标题部分)。
然后你想要它在主页上使用:
<img src="image.php">
您必须在 img 标签中调用此 php 页面
将图像写入文件系统,然后输出带有<img>
标签的 HTML 页面:
<?php
$im = new imagick('file.pdf[0]');
$im->setImageFormat('jpg');
$im->writeImage('/var/www/domain/image/something.png');
echo "<img src='/image/something.png'>";
请注意,该文件必须位于可公开访问的目录中