PHP-Imagemagick图像显示 [英] PHP-Imagemagick image display
本文介绍了PHP-Imagemagick图像显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有php代码创建pdf缩略图如下;
I have php code which create pdf thumbnail as follows;
<?php
$file ="test.pdf";
$im = new imagick(realpath($file).'[0]');
$im->setImageFormat("png");
$im->resizeImage(200,200,1,0);
header("Content-Type: image/jpeg");
$thumbnail = $im->getImageBlob();
echo $thumbnail;
?>
哪个效果很好。但是如果我想在网页中显示图像,我必须使用< img src =>
标记。有没有办法删除标题(Content-Type:image / jpeg);
来自语法和echo图像使用
< img src =>
..?或者任何人告诉我如何使用语法在网页中显示图像。
Which is working well. But if I want to display the image in a web page, I have to use <img src="">
tag. Is there any way to remove header("Content-Type: image/jpeg");
from the syntax and echo image using <img src="">
..? Or anybody tell me how to use the syntax to display the image inside a web page.
我在Windows Vista PC中运行带有php5的apache ..
I am running apache with php5 in my Windows Vista PC..
推荐答案
您可以尝试以这种方式显示图像:
you can try to display the image by this way:
// start buffering
ob_start();
$thumbnail = $im->getImageBlob();
$contents = ob_get_contents();
ob_end_clean();
echo "<img src='data:image/jpg;base64,".base64_encode($contents)."' />";
这篇关于PHP-Imagemagick图像显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文