wideimage lib - 无法使resizeCanvas()工作

时间:2013-10-24 13:48:57

标签: php wideimage

我想制作一个白色正方形,其中我将图像置于其中,但问题是我没有白色画布而得到图像。我收到了我上传(未处理)的相同图片。

$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 个答案:

答案 0 :(得分:1)

将第6行更改为

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