2013-10-24 44 views
0

我想製作一個白色方塊,其中我將圖像居中,但問題是我沒有使用白色畫布取回圖像。我找回了我上傳的相同圖片(未處理)。wideimage lib - 無法獲取resizeCanvas()的工作

$image = WideImage::loadFromFile(FILE_DIR."tmp/".$img); 
$h = $image->getHeight(); 
$w = $image->getWidth(); 
$biggestLength = max($w, $h); 
$white = $image->allocateColor(255, 255, 255); 
$image->resizeCanvas($biggestLength, $biggestLength, 'center', 'center', $white); 
$image->saveToFile(FILE_DIR."tmp/canvas.jpg"); 

http://wideimage.sourceforge.net/wp-content/current/doc/WideImage/WideImage_Image.html#methodresizeCanvas

回答

1

更改6行到

$image = $image->resizeCanvas($biggestLength, $biggestLength, 'center', 'center', $white);