【发布时间】:2017-09-29 16:51:00
【问题描述】:
我有 tiff 格式的图像,所以我想在 PHP 的上传过程中将其转换为 png 或 jpg,或者是否有任何其他方式或插件可以通过浏览器直接显示我的 tiif 图像?
【问题讨论】:
我有 tiff 格式的图像,所以我想在 PHP 的上传过程中将其转换为 png 或 jpg,或者是否有任何其他方式或插件可以通过浏览器直接显示我的 tiif 图像?
【问题讨论】:
PHP 发行版不支持图像处理, 所以需要用到ImageMagick,详情click here
您可以简单地编写这样的代码。
<?php
// create new imagick object from image.jpg
$im = new Imagick( "image.tiff" );
// change format to png
$im->setImageFormat( "png" );
// output the image to the browser as a png
//header( "Content-Type: image/png" );
//echo $im;
// or you could output the image to a file:
$im->writeImage( "image.png" );
?>
【讨论】: