aainaarz
aainaarz

Reputation: 902

wideimage lib - can't get resizeCanvas() to work

I want to make a white square in which I center image inside, but the problem is that I get back image without white canvas. i get back the same image that i uploaded (not processed).

$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

Upvotes: 0

Views: 377

Answers (1)

John Wong
John Wong

Reputation: 196

Change line 6 to

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

Upvotes: 1

Related Questions