2014-11-03 23 views

回答

16

這應該是一個下拉更換爲imagecrop()(沒有錯誤...):

function mycrop($src, array $rect) 
{ 
    $dest = imagecreatetruecolor($rect['width'], $rect['height']); 
    imagecopy(
     $dest, 
     $src, 
     0, 
     0, 
     $rect['x'], 
     $rect['y'], 
     $rect['width'], 
     $rect['height'] 
    ); 

    return $dest; 
} 

用法:

$img = mycrop($img, ['x' => 10, 'y' => 10, 'width' => 100, 'height' => 100]); 

注意,錯誤顯然是固定PHP 5.6.12

+1

顯然是完美的,但因爲這個問題不是真的,所以我會在提供答案之前通過解決方案。 – 2014-11-04 10:48:57

+0

我會將您的答案標記爲已接受,但使用我自己的標準,因爲此解決方案不適用於我的問題,並且此人未向我提供正確的反饋。我代表這個人,謝謝你。 – 2014-11-14 15:28:19