protected static function Create(
      int $type, int $width, int $height, int $gravity = Gravity::MIDDLE_CENTER,
      int $portraitLength = 0, int $landscapeLength = 0 )
      : ImageSizeReducer
   {

      switch ( $type )
      {

         case ImageSizeReducerType::CROP:
            if ( $width < 1 )
            {
               throw new ArgumentError( 'width', $width, 'Drawing.Image', 'Can not crop an image to a empty width!' );
            }
            if ( $height < 1 )
            {
               throw new ArgumentError( 'height', $height, 'Drawing.Image', 'Can not crop an image to a empty height!' );
            }
            if ( ! \in_array( $gravity, Gravity::KNOWN_VALUES ) )
            {
               $gravity = Gravity::MIDDLE_CENTER;
            }
            return static::CreateCropper( $width, $height, $gravity );

         case ImageSizeReducerType::RESIZE:
            if ( $width < 1 )
            {
               throw new ArgumentError( 'width', $width, 'Drawing.Image', 'Can not reduce an image to a empty width!' );
            }
            if ( $height < 1 )
            {
               throw new ArgumentError( 'height', $height, 'Drawing.Image', 'Can not reduce an image to a empty height!' );
            }
            return static::CreateResizer( $width, $height );

         case ImageSizeReducerType::LONG_SIDE:
            if ( $portraitLength < 1 )
            {
               throw new ArgumentError(
                  'portraitLength', $portraitLength, 'Drawing.Image',
                  'Can not reduce an image size to a empty side length!' );
            }
            if ( $landscapeLength < 1 )
            {
               throw new ArgumentError(
                  'landscapeLength', $landscapeLength, 'Drawing.Image',
                  'Can not reduce an image size to a empty side length!' );
            }
            return static::CreateLongSideReducer( $portraitLength, $landscapeLength );

         case ImageSizeReducerType::SHORT_SIDE:
            if ( $portraitLength < 1 )
            {
               throw new ArgumentError(
                  'portraitLength', $portraitLength, 'Drawing.Image',
                  'Can not reduce an image size to a empty side length!' );
            }
            if ( $landscapeLength < 1 )
            {
               throw new ArgumentError(
                  'landscapeLength', $landscapeLength, 'Drawing.Image',
                  'Can not reduce an image size to a empty side length!' );
            }
            return static::CreateShortSideReducer( $portraitLength, $landscapeLength );

         default:
            throw new ArgumentError(
               'type', $type, 'Drawing.Image',
               'Can not reduce an image size with a unknown reducer type!' );

      }

   }
protected static function Create(
      int $type, int $width, int $height, int $gravity = Gravity::MIDDLE_CENTER,
      int $portraitLength = 0, int $landscapeLength = 0 )
      : ImageSizeReducer
   {

      switch ( $type )
      {

         case ImageSizeReducerType::CROP:
            if ( $width < 1 )
            {
               throw new ArgumentError( 'width', $width, 'Drawing.Image', 'Can not crop an image to a empty width!' );
            }
            if ( $height < 1 )
            {
               throw new ArgumentError( 'height', $height, 'Drawing.Image', 'Can not crop an image to a empty height!' );
            }
            if ( ! \in_array( $gravity, Gravity::KNOWN_VALUES ) )
            {
               $gravity = Gravity::MIDDLE_CENTER;
            }
            return static::CreateCropper( $width, $height, $gravity );

         case ImageSizeReducerType::RESIZE:
            if ( $width < 1 )
            {
               throw new ArgumentError( 'width', $width, 'Drawing.Image', 'Can not reduce an image to a empty width!' );
            }
            if ( $height < 1 )
            {
               throw new ArgumentError( 'height', $height, 'Drawing.Image', 'Can not reduce an image to a empty height!' );
            }
            return static::CreateResizer( $width, $height );

         case ImageSizeReducerType::LONG_SIDE:
            if ( $portraitLength < 1 )
            {
               throw new ArgumentError(
                  'portraitLength', $portraitLength, 'Drawing.Image',
                  'Can not reduce an image size to a empty side length!' );
            }
            if ( $landscapeLength < 1 )
            {
               throw new ArgumentError(
                  'landscapeLength', $landscapeLength, 'Drawing.Image',
                  'Can not reduce an image size to a empty side length!' );
            }
            return static::CreateLongSideReducer( $portraitLength, $landscapeLength );

         case ImageSizeReducerType::SHORT_SIDE:
            if ( $portraitLength < 1 )
            {
               throw new ArgumentError(
                  'portraitLength', $portraitLength, 'Drawing.Image',
                  'Can not reduce an image size to a empty side length!' );
            }
            if ( $landscapeLength < 1 )
            {
               throw new ArgumentError(
                  'landscapeLength', $landscapeLength, 'Drawing.Image',
                  'Can not reduce an image size to a empty side length!' );
            }
            return static::CreateShortSideReducer( $portraitLength, $landscapeLength );

         default:
            throw new ArgumentError(
               'type', $type, 'Drawing.Image',
               'Can not reduce an image size with a unknown reducer type!' );

      }

   }
protected static function Create ( int $ type , int $ width , int $ height , int $ gravity = Gravity :: MIDDLE_CENTER , int $ portraitLength = 0 , int $ landscapeLength = 0 ) : ImageSizeReducer { switch ( $ type ) { case ImageSizeReducerType :: CROP : if ( $ width < 1 ) { throw new ArgumentError ( 'width' , $ width , 'Drawing.Image' , 'Can not crop an image to a empty width!' ) ; } if ( $ height < 1 ) { throw new ArgumentError ( 'height' , $ height , 'Drawing.Image' , 'Can not crop an image to a empty height!' ) ; } if ( ! \ in_array ( $ gravity , Gravity :: KNOWN_VALUES ) ) { $ gravity = Gravity :: MIDDLE_CENTER ; } return static :: CreateCropper ( $ width , $ height , $ gravity ) ; case ImageSizeReducerType :: RESIZE : if ( $ width < 1 ) { throw new ArgumentError ( 'width' , $ width , 'Drawing.Image' , 'Can not reduce an image to a empty width!' ) ; } if ( $ height < 1 ) { throw new ArgumentError ( 'height' , $ height , 'Drawing.Image' , 'Can not reduce an image to a empty height!' ) ; } return static :: CreateResizer ( $ width , $ height ) ; case ImageSizeReducerType :: LONG_SIDE : if ( $ portraitLength < 1 ) { throw new ArgumentError ( 'portraitLength' , $ portraitLength , 'Drawing.Image' , 'Can not reduce an image size to a empty side length!' ) ; } if ( $ landscapeLength < 1 ) { throw new ArgumentError ( 'landscapeLength' , $ landscapeLength , 'Drawing.Image' , 'Can not reduce an image size to a empty side length!' ) ; } return static :: CreateLongSideReducer ( $ portraitLength , $ landscapeLength ) ; case ImageSizeReducerType :: SHORT_SIDE : if ( $ portraitLength < 1 ) { throw new ArgumentError ( 'portraitLength' , $ portraitLength , 'Drawing.Image' , 'Can not reduce an image size to a empty side length!' ) ; } if ( $ landscapeLength < 1 ) { throw new ArgumentError ( 'landscapeLength' , $ landscapeLength , 'Drawing.Image' , 'Can not reduce an image size to a empty side length!' ) ; } return static :: CreateShortSideReducer ( $ portraitLength , $ landscapeLength ) ; default : throw new ArgumentError ( 'type' , $ type , 'Drawing.Image' , 'Can not reduce an image size with a unknown reducer type!' ) ; } }
Init an Image size reducer.

@param  int $type   The the image size reducer type
@param  int $width  The width of the required resulting image
@param  int $height The height of the required resulting image
@param  int $gravity The gravity of the cropped image part
@param  int $portraitLength
@param  int $landscapeLength
@return \Beluga\Drawing\Image\ImageSizeReducer
@throws \Beluga\ArgumentError
Init an Image size reducer .