php實現tif轉jpg
阿新 • • 發佈:2019-01-23
public function tifToJpg($filename){
$filepath = 'D:/xampp/htdocs//';
$jpgfilename = substr($filename,0,strrpos($filename,'.')).'.jpg';
$im = new Imagick($filepath.$filename);
$im->thumbnailImage(750, 0);
$width = $im->getImageWidth() ;
$height = $im->getImageHeight();
$width800 = 800;
$height800 = 800*$height/$width;
$canvas = new Imagick();
$canvas->newImage($width, $height, '');
$canvas->setImageFormat("jpeg");
$canvas->compositeImage($im, imagick::COMPOSITE_OVER, 20, 10);
$canvas->writeImage($filepath.$jpgfilename);
return $jpgfilename;
}