public function resizeImage($imageFile, $imageFieldOptions)
    {
        $image = Image::make($imageFile);

        // check if resize needed
        if (!$this->needResizing($imageFieldOptions)) {
            return $image;
        }

        // resize it according to options
        $width = array_get($imageFieldOptions, 'width');
        $height = array_get($imageFieldOptions, 'height');
        $cropHeight = empty($height) ? $width : $height;
        $crop = $this->getCropOption($imageFieldOptions);

        // crop it if option is set to true
        if ($crop === true) {
            $image->fit($width, $cropHeight, function ($constraint) {
                $constraint->upsize();
            });

            return $image;
        }

        // crop with x,y coordinate array
        if (is_array($crop) && count($crop) == 2) {
            list($x, $y) = $crop;

            $image->crop($width, $cropHeight, $x, $y);

            return $image;
        }

        // or resize it with given width and height
        $image->resize($width, $height, function ($constraint) {
            $constraint->aspectRatio();
            $constraint->upsize();
        });

        return $image;
    }
public function resizeImage($imageFile, $imageFieldOptions)
    {
        $image = Image::make($imageFile);

        // check if resize needed
        if (!$this->needResizing($imageFieldOptions)) {
            return $image;
        }

        // resize it according to options
        $width = array_get($imageFieldOptions, 'width');
        $height = array_get($imageFieldOptions, 'height');
        $cropHeight = empty($height) ? $width : $height;
        $crop = $this->getCropOption($imageFieldOptions);

        // crop it if option is set to true
        if ($crop === true) {
            $image->fit($width, $cropHeight, function ($constraint) {
                $constraint->upsize();
            });

            return $image;
        }

        // crop with x,y coordinate array
        if (is_array($crop) && count($crop) == 2) {
            list($x, $y) = $crop;

            $image->crop($width, $cropHeight, $x, $y);

            return $image;
        }

        // or resize it with given width and height
        $image->resize($width, $height, function ($constraint) {
            $constraint->aspectRatio();
            $constraint->upsize();
        });

        return $image;
    }
public function resizeImage ( $ imageFile , $ imageFieldOptions ) { $ image = Image :: make ( $ imageFile ) ; // check if resize needed if ( ! $ this -> needResizing ( $ imageFieldOptions ) ) { return $ image ; } // resize it according to options $ width = array_get ( $ imageFieldOptions , 'width' ) ; $ height = array_get ( $ imageFieldOptions , 'height' ) ; $ cropHeight = empty ( $ height ) ? $ width : $ height ; $ crop = $ this -> getCropOption ( $ imageFieldOptions ) ; // crop it if option is set to true if ( $ crop === true ) { $ image -> fit ( $ width , $ cropHeight , function ( $ constraint ) { $ constraint -> upsize ( ) ; } ) ; return $ image ; } // crop with x,y coordinate array if ( is_array ( $ crop ) && count ( $ crop ) == 2 ) { list ( $ x , $ y ) = $ crop ; $ image -> crop ( $ width , $ cropHeight , $ x , $ y ) ; return $ image ; } // or resize it with given width and height $ image -> resize ( $ width , $ height , function ( $ constraint ) { $ constraint -> aspectRatio ( ) ; $ constraint -> upsize ( ) ; } ) ; return $ image ; }
Resize image based on options

@param $imageFile
@param $imageFieldOptions array
@return \Intervention\Image\Image
Resize image based on options