We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

GD Adaptor Image resize & crop

I'm triying to resize and crop an image with the Phalcon\Image\Adapter\GD https://docs.phalcon.io/en/master/api/Phalcon_Image_Adapter_GD.html

The docs says

Resize the image to the given size. Either the width or the height can be omitted and the image will be resized proportionally.

but I tried with null and 0 on the first parameter and an exception is throw:

width and height must be specified



85.5k

only resize allows null as a parameters, is that how you use it ?

can we see the code ?

edited Sep '15

    public function testsAction()
    {
        try {
            $image = new Phalcon\Image\Adapter\Gd('absolute_path_on_server');
            $image->resize(null, 800);
            $image->save();
        } catch (\Exception $e) {
            $this->flash->error($e->getMessage());
        }
    }

throws width and height must be specified

$image->resize(null, 800);

You're trying to resize to Width = null, so it's throwing you the error. You need 2 values for your resize function adn they can't be null values : _resize (mixed $width, mixed $height)