Media Module - CanvasResize

  • Hi,

    I have written a ResizeCanvas class to also have this option possible as image manipulation because I was missing this option.
    Hereby the code. Please add this to the Media Module and documentation.
    Of course you are free to modify it to your needs.

    use Modules\Media\Image\ImageHandlerInterface;
    class ResizeCanvas implements ImageHandlerInterface
        private $defaults = [
            'width' => 100,
            'height' => 100,
            'anchor' => 'center',
            'relative' => false,
            'bgcolor' => 'rgba(255, 255, 255, 0)'
         * Handle the image manipulation request
         * @param  \Intervention\Image\Image $image
         * @param  array                     $options
         * @return \Intervention\Image\Image
        public function handle($image, $options)
            $options = array_merge($this->defaults, $options);
            return $image->resizeCanvas($options['width'], $options['height'], $options['anchor'], $options['relative'], $options['bgcolor']);

    Best regards,

  • admin

    Thanks ! Will do.

  • admin

    Hello again,

    This is now added on asgardcms v2, updated the documentation as well.

    Thanks again for the tip.

  • Your welcome, it would also be nice to add it to v1 for projects build in v1 and where is not time and money to upgrade to v2 :)

Log in to reply

Looks like your connection to AsgardCms was lost, please wait while we try to reconnect.