public function fit($width = null, $heigth = null, array $options = [])
    {
        $heigth = $heigth ?: $width;
        $width = $width ?: $heigth;

        //Sets default options
        $options += ['position' => 'center', 'upsize' => true];

        //Adds arguments
        $this->arguments[] = [__FUNCTION__, $width, $heigth, $options];

        //Adds the callback
        $this->callbacks[] = function (Image $imageInstance) use ($width, $heigth, $options) {
            return $imageInstance->fit($width, $heigth, function (Constraint $constraint) use ($options) {
                if ($options['upsize']) {
                    $constraint->upsize();
                }
            }, $options['position']);
        };

        return $this;
    }
public function fit($width = null, $heigth = null, array $options = [])
    {
        $heigth = $heigth ?: $width;
        $width = $width ?: $heigth;

        //Sets default options
        $options += ['position' => 'center', 'upsize' => true];

        //Adds arguments
        $this->arguments[] = [__FUNCTION__, $width, $heigth, $options];

        //Adds the callback
        $this->callbacks[] = function (Image $imageInstance) use ($width, $heigth, $options) {
            return $imageInstance->fit($width, $heigth, function (Constraint $constraint) use ($options) {
                if ($options['upsize']) {
                    $constraint->upsize();
                }
            }, $options['position']);
        };

        return $this;
    }
public function fit ( $ width = null , $ heigth = null , array $ options = [ ] ) { $ heigth = $ heigth ? : $ width ; $ width = $ width ? : $ heigth ; //Sets default options $ options += [ 'position' => 'center' , 'upsize' => true ] ; //Adds arguments $ this -> arguments [ ] = [ __FUNCTION__ , $ width , $ heigth , $ options ] ; //Adds the callback $ this -> callbacks [ ] = function ( Image $ imageInstance ) use ( $ width , $ heigth , $ options ) { return $ imageInstance -> fit ( $ width , $ heigth , function ( Constraint $ constraint ) use ( $ options ) { if ( $ options [ 'upsize' ] ) { $ constraint -> upsize ( ) ; } } , $ options [ 'position' ] ) ; } ; return $ this ; }
Resizes the image, combining cropping and resizing to format image in a
smart way. It will find the best fitting aspect ratio on the current
image automatically, cut it out and resize it to the given dimension
@param int $width Required width
@param int $heigth Required heigth
@param array $options Options for the thumbnail
@return \Thumber\Utility\ThumbCreator
@see https://github.com/mirko-pagliai/cakephp-thumber/wiki/How-to-uses-the-ThumbCreator-utility#fit
@uses $arguments
@uses $callbacks
Resizes the image combining cropping and resizing to format image in a smart way . It will find the best fitting aspect ratio on the current image automatically cut it out and resize it to the given dimension