简体   繁体   中英

How to convert tiff format ti jpg or png foemat during upload in PHP

我有tiff格式的图像,因此我想在PHP的上传过程中将其转换为png或jpg,或者有其他方法或插件可以直接通过浏览器显示我的tiif图像吗?

PHP distribution does not support image processing, So you need to use ImageMagick, for details click here

You can simplly write a code like this.

<?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" );
?>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM