1

Trying to resize and image to width. This is the code:

<?php
require 'vendor/autoload.php';

use Imagine\Image\Box;
use Imagine\Image\Point;

$imagine = new Imagine\Gd\Imagine();

$image = $imagine->open('img.jpg');

$image->widen(600)->save('resized_img.jpg');

?>

and the error:

PHP Fatal error:  Call to undefined method Imagine\Gd\Image::widen() in resize.php on line 11

What am i doing wrong?

Andy
  • 31
  • 4
  • You're calling a method that doesn't exist. – Jimmy T. Feb 19 '17 at 17:03
  • According documentation it does exist: http://imagine.readthedocs.io/en/latest/_static/API/Imagine/Image/BoxInterface.html#method_widen – Andy Feb 19 '17 at 17:14
  • The documentation says that `widen` is a method of `BoxInterface`, but `$imagine` is not an instance of `BoxInterface`. `$imagine` is not a box. – Jimmy T. Feb 19 '17 at 18:09

1 Answers1

2

Ok, so here's the proper way to do that:

<?php
require 'vendor/autoload.php';

use Imagine\Image\Box;
use Imagine\Image\Point;

$imagine = new Imagine\Gd\Imagine();

$image = $imagine->open('img.jpg');

$image->resize($image->getSize()->widen(600))->save('resized_img.jpg');

?>
Andy
  • 31
  • 4