原圖: 這裏我需要什麼: 應該從這個小瓦創建: 如何在不使用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,但我不知道如何實現它這樣正確的方法。
什麼是錯的使用PHP的exec()調整顏色的厚度?這使得它可以很容易地使用預先存在的解決方案,而不必去創造它一遍 – fmw42
@ fmw42是的,你是對的,它很容易使用,方便易,但使用了很多客戶的共享主機不提供訪問到PHP exec()或者我不是? – kostya572
我對Imagick並沒有太多的嘗試,並沒有嘗試過,但是http://us3.php.net/manual/en/imagick.textureimage.php是將平鋪圖像的函數。你應該能夠使用它來實現你想要的結果。 – fmw42