PHP 使用ImageMagic正片疊底

<?php
/**
 * -compose 後面的參數爲混合模式
 * 混合模式中英文對照
1. 正常(Normal)模式
2. 溶解(Dissolve)模式
3. 變暗(Darken)模式
4. 正片疊底(Multiply)模式
5. 顏色加深(ColorBurn)模式
6. 線性加深(LinearBurn)模式
7. 變亮(Lighten)模式
8. 濾色(Screen)模式
9. 顏色減淡(ColorDodge)模式
10. 線性減淡(LinearDodge)模式
11. 疊加(Overlay)模式
12. 柔光(SoftLight)模式
13. 強光(HardLight)模式
14. 亮光(VividLight)模式
15. 線性光(LinearLight)模式
16. 點光(PinLight)模式
17. 差值(Difference)模式
18. 排除(Exclusion)模式
19. 色相(Hue)模式
20. 飽和度(Saturation)模式
21. 顏色(Color)模式
22. 亮度(Luminosity)模式
 *
 */



$cur_proto = '123.png';
$cur_pic_png_alpha = '300.png';
$protomerge_pic = 'new.jpg';
shell_exec("convert {$cur_proto} {$cur_pic_png_alpha} -geometry +102+120 -compose Difference -composite {$protomerge_pic}");

//-geometry 疊加到指定位置座標
//-compose 混合模式
/*$img='/vagrant_data/vagrant_test/kou/1.jpg';//背景圖
$img2='/vagrant_data/vagrant_test/kou/2.jpg';//疊加圖
$img3='/vagrant_data/vagrant_test/kou/123.jpg';
shell_exec("convert {$img} {$img2} -geometry +150+80 -compose Multiply -composite ouput.jpg");
shell_exec("convert {$img3} {$img2} -geometry +150+80 -compose Multiply -composite ouput1.jpg");*/

$cur_pic_png_alpha = 'http://bpic.588ku.com//original_origin_pic/18/06/06/91a3d2288873a3c9b2bc934f6716d0d3.png!/fw/300';
$proto_bg = '/vagrant_data/vagrant_test/kou/手機殼底圖.png';
$cur_proto = '/vagrant_data/vagrant_test/kou/手機殼2.png';

$protomerge_pic = 'output.jpg';
#+120 +80 代表的是x,y的座標,具體的根據情況設定
shell_exec("convert {$cur_proto} {$cur_pic_png_alpha} -geometry +120+80 -compose Multiply -composite {$protomerge_pic}");

$create_proto_pic = 'output1.jpg';
//再與樣機圖背景疊底,生成合並樣機圖
shell_exec("convert {$protomerge_pic} -compose over {$proto_bg} -geometry 512x512+0+0 -quality 100 -composite {$create_proto_pic}");

必須安裝ImageMagic哦。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章