2017-06-04 12 views
1

原圖: Original image 這裏我需要什麼: Here what i need 應該從這個小瓦創建: It should be created from this small tile如何在不使用exec函數的情況下製作平鋪的圖像幀?

很多人建議使用ImageMagick的解決方案(使用PHP exec函數吧) - http://www.imagemagick.org/discourse-server/viewtopic.php?f=1&t=21867

convert frame_template.gif \ 
-tile blackthin_top.gif -draw 'color 1,0 floodfill' -rotate 90 \ 
-tile blackthin_btm.gif -draw 'color 1,0 floodfill' -rotate 90 \ 
-tile blackthin_top.gif -draw 'color 1,0 floodfill' -rotate 90 \ 
-tile blackthin_btm.gif -draw 'color 1,0 floodfill' -rotate 90 \ 
-gravity center thumbnail.gif -composite frame_filled.gif 

PICFrame溶液(使用PHP exec函數它) - http://www.fmwconcepts.com/imagemagick/picframe/index.php

picframe [-f frameid] [-m mattesize] [-c mattecolor] [-b bordersize] [-s shade] [-a adjust] [-o opacity ] [-d distance] infile outfile 

PHP imagick具有創建彩色邊框與偉大的能力:

$imagick = new \Imagick('image.jpg'); 
$imagick->scaleImage(300, 300, false); 

// Create frame placeholder 
$imagick->frameimage('red','30','30', 30, 0); 

// Flood fill with color 
$imagick->floodFillPaintImage('green', 10, '#6e0000',0, 0,false 
); 

header("Content-Type: image/jpg"); 
echo $imagick->getImageBlob(); 

但是PHP imagick不能使用自己的圖像平鋪創建框架,只有純色。這是非常相關的問題 - How to flood fill the frame with a pattern image using imagick php class?

另一個很好的解決方案 - https://stackoverflow.com/a/28778953/2337706,但它創建大的PNG幀的圖像,你應該知道正確的圖像大小。

我知道,我可以用PHP GD創建 - http://php.net/manual/en/ref.image.php,但我不知道如何實現它這樣正確的方法。

+0

什麼是錯的使用PHP的exec()調整顏色的厚度?這使得它可以很容易地使用預先存在的解決方案,而不必去創造它一遍 – fmw42

+0

@ fmw42是的,你是對的,它很容易使用,方便易,但使用了很多客戶的共享主機不提供訪問到PHP exec()或者我不是? – kostya572

+0

我對Imagick並沒有太多的嘗試,並沒有嘗試過,但是http://us3.php.net/manual/en/imagick.textureimage.php是將平鋪圖像的函數。你應該能夠使用它來實現你想要的結果。 – fmw42

回答

0

在ImageMagick的,你可能只是做一些簡單的像這樣:

convert a1Wit.jpg -mattecolor black -frame 10x10+3+3 -gravity west -chop 3x0 -bordercolor gold -border 3 frame_result.jpg 

enter image description here

這些命令應該是很容易轉化爲Imagick。見http://us3.php.net/manual/en/imagick.frameimage.phphttp://us3.php.net/manual/en/imagick.chopimage.phphttp://us3.php.net/manual/en/imagick.borderimage.php

或者乾脆:

convert a1Wit.jpg -bordercolor black -border 7 -bordercolor "gray(35%)" -border 3 -bordercolor "#D0A456" -border 3 frame_result2.jpg 

enter image description here

或者

convert a1Wit.jpg -mattecolor "gray(30%)" -frame 13x13+5+5 -gravity northwest -shave 5x5 -bordercolor "#D0A456" -border 3 frame_result3.jpg 

enter image description here

或者

convert a1Wit.jpg -mattecolor "gray(30%)" -frame 13x13+5+5 -gravity northwest -bordercolor "#D0A456" -border 3 frame_result4.jpg 

enter image description here

根據需要

相關問題