phpwideimage

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


Solution

  • Change line 6 to

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