Init an Image size reducer of type SHORT_SIDE (see {@see \Beluga\Drawing\Image\ImageSizeReducerType::SHORT_SIDE})

@param  int $portraitLength
@param  int $landscapeLength
@return \Beluga\Drawing\Image\ImageSizeReducer
@throws \Beluga\ArgumentError
484777
public static function CreateShortSideReducer( int $portraitLength, int $landscapeLength ) : ImageSizeReducer
   {

      if ( $portraitLength <= 0 )
      {
         throw new ArgumentError(
            'portraitLength', $portraitLength, 'Drawing.Image', 'Can not reduce an image to a empty side length!' );
      }

      if ( $landscapeLength <= 0 )
      {
         throw new ArgumentError(
            'landscapeLength', $landscapeLength, 'Drawing.Image', 'Can not reduce an image to a empty side length!' );
      }

      return ( new ImageSizeReducer( ImageSizeReducerType::SHORT_SIDE ) )
         ->setLandscape( $landscapeLength )
         ->setPortrait( $portraitLength );

   }
529451
public function setWidth( int $width ) : ImageSizeReducer
   {

      if ( $width <= 0 )
      {
         throw new ArgumentError( 'width', $width, 'Drawing.Image', 'Can not crop an image with an empty width!' );
      }

      $this->data[ 'width' ] = $width;

      return $this;

   }
977591
private int getRotationAngle(final ExifInterface exifInterface) {
    return JfifUtil.getAutoRotateAngleFromOrientation(
        Integer.parseInt(exifInterface.getAttribute(ExifInterface.TAG_ORIENTATION)));
  }
486723
public function setMaxlength($maxlength)
    {
        if (empty((int) $maxlength)) {
            Throw new HtmlException('A html form textareas maxlength attribute needs to be of type integer.');
        }

        $this->attribute['maxlength'] = $maxlength;

        return $this;
    }
759628
public static function rounded($radius, $sides = null, $antialias = null)
	{
		return static::instance()->rounded($radius, $sides, $antialias);
	}
629184
public function plainCookie($key, $minLength = 0, $maxLength = false, $default = false)
	{
		return $this->plain($this->cookie($key), $minLength, $maxLength, $default);
	}
728642
public function setPaper($size, $orientation = "portrait")
    {
        $this->paperSize = $size;
        $this->paperOrientation = $orientation;
        return $this;
    }
899380
private function getSizeByAuto($newWidth, $newHeight)
        {
            // Image to be resized is wider (landscape).
            if ($this->height < $this->width) {
                $optimalWidth  = $newWidth;
                $optimalHeight = $this->getSizeByFixedWidth($newWidth);
            } else if ($this->height > $this->width) {
                $optimalWidth  = $this->getSizeByFixedHeight($newHeight);
                $optimalHeight = $newHeight;
            }  else {
                if ($newHeight < $newWidth)
                {
                    $optimalWidth  = $newWidth;
                    $optimalHeight = $this->getSizeByFixedWidth($newWidth);
                } else if ($newHeight > $newWidth) {
                    $optimalWidth  = $this->getSizeByFixedHeight($newHeight);
                    $optimalHeight = $newHeight;
                } else {
                    // Sqaure being resized to a square.
                    $optimalWidth  = $newWidth;
                    $optimalHeight = $newHeight;
                }
            }

            return array(
                'optimalWidth'     => $optimalWidth,
                'optimalHeight'    => $optimalHeight
           );
        }
405084
public function minLength($key, $minLength, $message = null)
    {
        if (is_array($key)) {
            foreach ($key as $k => $name) {
                $this->minLength($name, is_array($minLength) ? $minLength[$k] : $minLength, $message);
            }
        } else {
            if (isset($this->scope[$key]) && mb_strlen($this->scope[$key]) < $minLength) {
                $this->errors[$key] = sprintf($message !== null ? $message : self::$minLengthMessage, $key, $minLength);
            }
        }

        return $this;
    }
241232
private function getDimensions($newWidth, $newHeight, $option)
		# Author:     Jarrod Oberto
		# Date:       17-11-09
		# Purpose:    Get new image dimensions based on user specificaions
		# Param in:   $newWidth:
		#             $newHeight:
		# Param out:  Array of new width and height values
		# Reference:
		# Notes:    If $option = 3 then this function is call recursivly
		#
		#       To clarify the $option input:
		#               0 = The exact height and width dimensions you set.
		#               1 = Whatever height is passed in will be the height that
		#                   is set. The width will be calculated and set automatically
		#                   to a the value that keeps the original aspect ratio.
		#               2 = The same but based on the width.
		#               3 = Depending whether the image is landscape or portrait, this
		#                   will automatically determine whether to resize via
		#                   dimension 1,2 or 0.
		#               4 = Resize the image as much as possible, then crop the
		#         remainder.
	{

		switch (strval($option))
		{
			case '0':
			case 'exact':
				$optimalWidth = $newWidth;
				$optimalHeight = $newHeight;
				break;
			case '1':
			case 'portrait':
				$dimensionsArray = $this->getSizeByFixedHeight($newWidth, $newHeight);
				$optimalWidth = $dimensionsArray['optimalWidth'];
				$optimalHeight = $dimensionsArray['optimalHeight'];
				break;
			case '2':
			case 'landscape':
				$dimensionsArray = $this->getSizeByFixedWidth($newWidth, $newHeight);
				$optimalWidth = $dimensionsArray['optimalWidth'];
				$optimalHeight = $dimensionsArray['optimalHeight'];
				break;
			case '3':
			case 'auto':
				$dimensionsArray = $this->getSizeByAuto($newWidth, $newHeight);
				$optimalWidth = $dimensionsArray['optimalWidth'];
				$optimalHeight = $dimensionsArray['optimalHeight'];
				break;
			case '4':
			case 'crop':
				$dimensionsArray = $this->getOptimalCrop($newWidth, $newHeight);
				$optimalWidth = $dimensionsArray['optimalWidth'];
				$optimalHeight = $dimensionsArray['optimalHeight'];
				break;
		}

		return array( 'optimalWidth' => $optimalWidth, 'optimalHeight' => $optimalHeight );
	}
712969
public function resizeAction($mode, $width, $height, $path)
    {
        try {
            $resizer = $this->get('graphql_extensions.image_resizer');

            $object = new LocatedObject($path);

            $config = [
                'width'  => $width,
                'height' => $height,
                'mode'   => $mode
            ];
            $resizer->resize($object, $config);

            return new RedirectResponse($resizer->getPathResolver()->resolveWebResizablePath($config, $object), 301);
        } catch (\Exception $e) {
            throw $this->createNotFoundException();
        }
    }
516235
protected static function stringLengthBetween(int $min, int $max, RuleInterface $next = null): RuleInterface
    {
        return $next === null ?
            new StringLengthBetween($min, $max) :
            new AndOperator(static::stringLengthBetween($min, $max), $next);
    }
327478
public function strGet($key, $minLength = 0, $maxLength = false, $default = false)
	{
		return $this->str($this->get($key), $minLength, $maxLength, $default);
	}
1068504
static public function betweenLength($value, $minLength, $maxLength, $message = null, $propertyPath = null, $encoding = 'utf8')
        {
            static::string($value, $message);

            if (mb_strlen($value, $encoding) < $minLength) {
                $message = $message ?: sprintf(
                    'Value "%s" is too short, it should have more than %d characters, but only has %d characters.',
                    static::stringify($value),
                    $minLength,
                    mb_strlen($value, $encoding)
                );

                $constraints = array('min_length' => $minLength, 'encoding' => $encoding);

                throw static::createException($value, $message, static::INVALID_MIN_LENGTH, $propertyPath, $constraints);
            }

            if (mb_strlen($value, $encoding) > $maxLength) {
                $message = $message ?: sprintf(
                    'Value "%s" is too long, it should have no more than %d characters, but has %d characters.',
                    static::stringify($value),
                    $maxLength,
                    mb_strlen($value, $encoding)
                );

                $constraints = array('max_length' => $maxLength, 'encoding' => $encoding);

                throw static::createException($value, $message, static::INVALID_MAX_LENGTH, $propertyPath, $constraints);
            }
        }
1146015
public static function validateFormatLength($formatLength)
    {
        if (!in_array($formatLength, [self::FORMAT_LENGTH_DEFAULT, self::FORMAT_LENGTH_FULL, self::FORMAT_LENGTH_LONG, self::FORMAT_LENGTH_MEDIUM, self::FORMAT_LENGTH_SHORT])) {
            throw new Exception\InvalidFormatLengthException('Provided formatLength, "' . $formatLength . '", is not one of allowed values.', 1281442591);
        }
    }
582841
public static function fromFocalLength($focalLength)
    {
        if (!is_string($focalLength)) {
            throw new InvalidArgumentException('focalLength must be a string');
        }

        if (!preg_match('#^f/([0-9]*\.[0-9]+|[0-9]*)$#', $focalLength, $matches)) {
            throw new RuntimeException('Given focalLength is not in a valid format. Need: "f/<number>"');
        }

        $fNumber = $matches[1];

        if (($filtered = filter_var($fNumber, FILTER_VALIDATE_INT)) !== false) {
            $fNumber = $filtered;
        } else {
            $fNumber = (float) $fNumber;
        }

        return new self($fNumber);
    }
443819
public function resizeImage($newWidth, $newHeight, $option = 0, $sharpen = false, $autoRotate = false)
		# Author:     Jarrod Oberto
		# Date:       27-02-08
		# Purpose:    Resizes the image
		# Param in:   $newWidth:
		#             $newHeight:
		#             $option:     0 / exact = defined size;
		#                          1 / portrait = keep aspect set height;
		#                          2 / landscape = keep aspect set width;
		#                          3 / auto = auto;
		#                          4 / crop= resize and crop;
		#
		#         $option can also be an array containing options for
		#         cropping. E.G., array('crop', 'r')
		#
		#         This array only applies to 'crop' and the 'r' refers to
		#         "crop right". Other value include; tl, t, tr, l, m (default),
		#         r, bl, b, br, or you can specify your own co-ords (which
		#         isn't recommended.
		#
		#       $sharpen:    true: sharpen (jpg only);
		#                false: don't sharpen
		# Param out:  n/a
		# Reference:
		# Notes:      To clarify the $option input:
		#               0 = The exact height and width dimensions you set.
		#               1 = Whatever height is passed in will be the height that
		#                   is set. The width will be calculated and set automatically
		#                   to a the value that keeps the original aspect ratio.
		#               2 = The same but based on the width. We try make the image the
		#                  biggest size we can while stil fitting inside the box size
		#               3 = Depending whether the image is landscape or portrait, this
		#                   will automatically determine whether to resize via
		#                   dimension 1,2 or 0
		#               4 = Will resize and then crop the image for best fit
		#
		#       forceStretch can be applied to options 1,2,3 and 4
		#
	{

		// *** We can pass in an array of options to change the crop position
		$cropPos = 'm';
		if (is_array($option) && fix_strtolower($option[0]) == 'crop')
		{
			$cropPos = $option[1];         # get the crop option
		}
		else
		{
			if (strpos($option, '-') !== false)
			{
				// *** Or pass in a hyphen seperated option
				$optionPiecesArray = explode('-', $option);
				$cropPos = end($optionPiecesArray);
			}
		}

		// *** Check the option is valid
		$option = $this->prepOption($option);

		// *** Make sure the file passed in is valid
		if ( ! $this->image)
		{
			if ($this->debug)
			{
				throw new Exception('file ' . $this->getFileName() . ' is missing or invalid');
			}
			else
			{
				throw new Exception();
			}
		};

		// *** Get optimal width and height - based on $option
		$dimensionsArray = $this->getDimensions($newWidth, $newHeight, $option);

		$optimalWidth = $dimensionsArray['optimalWidth'];
		$optimalHeight = $dimensionsArray['optimalHeight'];

		// *** Resample - create image canvas of x, y size
		$this->imageResized = imagecreatetruecolor($optimalWidth, $optimalHeight);
		$this->keepTransparancy($optimalWidth, $optimalHeight, $this->imageResized);
		imagecopyresampled($this->imageResized, $this->image, 0, 0, 0, 0, $optimalWidth, $optimalHeight, $this->width, $this->height);


		// *** If '4', then crop too
		if ($option == 4 || $option == 'crop')
		{

			if (($optimalWidth >= $newWidth && $optimalHeight >= $newHeight))
			{
				$this->crop($optimalWidth, $optimalHeight, $newWidth, $newHeight, $cropPos);
			}
		}

		// *** If Rotate.
		if ($autoRotate)
		{

			$exifData = $this->getExif(false);
			if (count($exifData) > 0)
			{

				switch ($exifData['orientation'])
				{
					case 8:
						$this->imageResized = imagerotate($this->imageResized, 90, 0);
						break;
					case 3:
						$this->imageResized = imagerotate($this->imageResized, 180, 0);
						break;
					case 6:
						$this->imageResized = imagerotate($this->imageResized, -90, 0);
						break;
				}
			}
		}

		// *** Sharpen image (if jpg and the user wishes to do so)
		if ($sharpen && in_array($this->fileExtension, $this->sharpenArray))
		{

			// *** Sharpen
			$this->sharpen();
		}
	}