imagemagick生成缩咯图+水印

首先要在服务器安装imagemagick(http://www.imagemagick.org/script/download.php) 然后看一下 php环境是否安装了imagick 模块,要按装,imagemagick是命令行操作,imagemagick里面有好多命令composite、convert等,命令有好多参数不一一介绍需要的自己去找度娘,当然也有php的api接口,但是兼容性不太好,所以直接用的命令行

生成缩咯图:

 

$exec_str = '/usr/bin/convert -quality 80 -geometry '.$lessen_width.'x'.$lessen_height.' '.$img.' '.$dir.$filename;

 @exec($exec_str, $output, $return);

 

添加水印的命令:

 $ssm="/usr/bin/composite -quality 0 -gravity ".$gravity." ".$watermark." ".$filename." ".$target; 

 @exec($ssm, $output, $return);

 

 

/usr/bin/composite -quality 0 -gravity NorthWest /home/mengdewei/www/test/水印.gif /home/mengdewei/www/test/image.jpg /home/mengdewei/www/test/image.jpg

 

本文出自 “享受编程” 博客,转载请与作者联系!

你可能感兴趣的:(return,安装,兼容性,convert,的)