2017-04-01 37 views
-1

我正在使用Intervention Image來製作一個框架。現在我卡在一個部分切斷邊緣。我需要這些圖像中的4個以使它們適合作爲框架。我知道我可以使用干預圖像庫來旋轉圖像,但我不知道切割這些角落。任何人都有一個想法如何實現這一點?在圖像中切角PHP

原文:

結果:

回答

1

您需要創建兩個多邊形,並用透明的顏色填充。

http://image.intervention.io/api/polygon

一個例子:

$img = Image::make('foo/bar/baz.jpg')->encode('png'); 
$w = $img->width(); 
$h = $img->height(); 
$points = [0,0,$width,0,$width,$width,0,0]; 
$img->polygon($points, function($d) { 
    $d->background("transparent"); 
}); 
$points = [0,$height,$width,$height,$width,$height-$width,0,$height]; 
$img->polygon($points, function($d) { 
    $d->background("transparent"); 
}); 
$img->save('foo/bar/baz_cut.png'); // jpg won't have transparency 
+0

我使用的背景( '透明'),但是然後我接收到的錯誤:無法讀取色(透明)。任何想法可能是什麼? –

+1

然後您可以使用'rgba(0,0,0,0)'來獲得該透明度。 –

+0

是的,我見過那個伴侶,謝謝!有那個伎倆。你是我的救世主! –