Home > Backend Development > PHP Tutorial > imagemagick叠图

imagemagick叠图

WBOY
Release: 2016-06-23 14:00:31
Original
1259 people have browsed it

请问怎么用imagemagick库实现GD库中imagecopyresampled的功能?把两张图叠在一起,看英文文档快看吐了,求捷径,哪怕告诉一个方法名我自己去研究,多谢!


回复讨论(解决方案)

//打开文件$imgA = "phpcn_logo.gif";$imgB = "phpchina.gif";$sourceImg = imagecreatefromgif($imgA);$targetImg = imagecreatefromgif($imgB);//获取文件大小$sourceSize = getimagesize($imgA);$targetSize = getimagesize($imgB);//合并图片imagecopyresized($targetImg, $sourceImg, 0, 0, 0, 0, $targetSize[0], $targetSize[1], $sourceSize[0], $sourceSize[1]);//保存结果$r = imagegif($targetImg, "c.gif");if($r){        echo "成功";}else{        echo "失败";}
Copy after login
Copy after login

//打开文件$imgA = "phpcn_logo.gif";$imgB = "phpchina.gif";$sourceImg = imagecreatefromgif($imgA);$targetImg = imagecreatefromgif($imgB);//获取文件大小$sourceSize = getimagesize($imgA);$targetSize = getimagesize($imgB);//合并图片imagecopyresized($targetImg, $sourceImg, 0, 0, 0, 0, $targetSize[0], $targetSize[1], $sourceSize[0], $sourceSize[1]);//保存结果$r = imagegif($targetImg, "c.gif");if($r){        echo "成功";}else{        echo "失败";}
Copy after login
Copy after login
不要GD库,这个我已经实现了,因为速度太慢,想换imagemagick

已经实现,文档看吐了,贴代码啥也不说了

$image = new Imagick('05.png');$imagepng = new Imagick('16.png');$imagepng->setImageFormat("png");$image->compositeImage($imagepng, $imagepng->getImageCompose(), 0, 0);$imagepng->destroy();header("Content-Type: image/png");echo $image;$image->destroy();
Copy after login

直接用imagick。

$cmd = sprintf("composite -gravity %s -geometry %s -dissolve %s '%s' %s %s", 'SouthEast', '+10+10', 100, '16.png', '05.png', '05.png');  exec($cmd); 
Copy after login
Copy after login

直接用imagick。

$cmd = sprintf("composite -gravity %s -geometry %s -dissolve %s '%s' %s %s", 'SouthEast', '+10+10', 100, '16.png', '05.png', '05.png');  exec($cmd); 
Copy after login
Copy after login
 
谢谢,我要直接输出,直接用shell不知道可不可行,另外将来可能往iis上移植,还是用扩展保险一些

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template