WidenAndHeighten

@param array Array of options for processing the image.
@throws \InvalidArgumentException
@return $this
331792
public function widenAndHeighten(array $options = []) {
		if (empty($options['height']) && empty($options['width']) && empty($options['size'])) {
			throw new \InvalidArgumentException(__d('imagine', 'You have to pass a height, width or size!'));
		}

		if (!empty($options['height']) && !empty($options['width'])) {
			throw new \InvalidArgumentException(__d('imagine', 'You can only scale by width or height!'));
		}

		if (isset($options['width'])) {
			$size = $options['width'];
			$method = 'widen';
		} elseif (isset($options['height'])) {
			$size = $options['height'];
			$method = 'heighten';
		} else {
			$size = $options['size'];
			$method = 'scale';
		}

		$imageSize = $this->getImageSize($this->_image);
		$width = $imageSize[0];
		$height = $imageSize[1];

		if (isset($options['noUpScale'])) {
			if ($method === 'widen') {
				if ($size > $width) {
					throw new \InvalidArgumentException('You can not scale up!');
				}
			} elseif ('heighten') {
				if ($size > $height) {
					throw new \InvalidArgumentException('You can not scale up!');
				}
			}
		}

		if (isset($options['noDownScale'])) {
			if ($method === 'widen') {
				if ($size < $width) {
					throw new \InvalidArgumentException('You can not scale down!');
				}
			} elseif ('heighten') {
				if ($size < $height) {
					throw new \InvalidArgumentException('You can not scale down!');
				}
			}
		}

		$Box = new Box($width, $height);
		$Box = $Box->{$method}($size);
		$this->_image->resize($Box);
		return $this;
	}
742638
public function setDimension($maxWidth, $maxHeight)
    {
      if ( (int) $maxWidth && (int) $maxHeight) {
        $this->dimensions = array($maxWidth, $maxHeight);
      } else {
        $this->error = $this->commonUploadErrors[$this->language]['ERROR_03'];
      }

      return $this;
    }
746458
public function batchSize($batchSize)
    {
        if (null !== $batchSize) {
            if (!is_numeric($batchSize) || $batchSize != (int) $batchSize) {
                throw new \InvalidArgumentException('The batchSize is not valid.');
            }
            $batchSize = (int) $batchSize;
        }

        $this->batchSize = $batchSize;

        return $this;
    }
533331
protected function setThumbnailHeight($height)
    {
        $this->writeAttribute(
            $height,
            'thumbnail',
            'height',
            $this->validator,
            'validateHeight',
            $this->exception,
            'Provided height is not a valid value.'
        );

        return $this;
    }
1026103
public function setWidth($width)
    {
        if (!is_null($width)) {
            if (intval($width) < 0) {
                throw new \InvalidArgumentException(sprintf('Invalid width: %d', $width));
            }

            $this->width = intval($width);
        } else {
            $this->width = null;
        }

        return $this;
    }
280878
public function squareCenterCrop(array $options = []) {
		if (empty($options['size'])) {
			throw new \InvalidArgumentException(__d('imagine', 'You have to pass size in the options!'));
		}

		$imageSize = $this->getImageSize($this->_image);

		$width = $imageSize[0];
		$height = $imageSize[1];

		if ($width > $height) {
			$x2 = $height;
			$y2 = $height;
			$x = ($width - $height) / 2;
			$y = 0;
		} else {
			$x2 = $width;
			$y2 = $width;
			$x = 0;
			$y = ($height - $width) / 2;
		}

		$this->_image->crop(new \Imagine\Image\Point($x, $y), new \Imagine\Image\Box($x2, $y2));
		$this->_image->resize(new \Imagine\Image\Box($options['size'], $options['size']));
		return $this;
	}
224990
protected function setHeight($height)
	{
		if ( ! is_numeric($height) || $height < 1)
		{
			throw new \InvalidArgumentException('Wrong the height value.');
		}
		
		$this->height = $height;
		
		return $this;
	}
782660
public function resizeToHeight ($image, $height)
		{
			$ratio = $height / $image->getSize()->getHeight();
			$width = $image->getSize()->getWidth() * $ratio;
			$this->_resize($image, new Box($width, $height));

			return $this;
		}
591898
public function setMinLength($minLength)
    {
        if (!is_integer($minLength)) {
            throw new InvalidArgumentException(
                'Min length must be an integer.'
            );
        }

        if ($minLength < 0) {
            throw new InvalidArgumentException(
                'Min length must be a positive integer (>=0).'
            );
        }

        $this->minLength = $minLength;

        return $this;
    }
127796
public function size($int_width, $int_height)
    {
        if (!is_integer($int_width) || !is_integer($int_height) || $int_width < 0 || $int_height < 0) {
            throw new \InvalidArgumentException('Width and height must be positive integers!');
        }

        $this->size->w = $int_width;
        $this->size->h = $int_height;

        return $this;
    }
375557
public function setAvatarSize($size)
    {
        $this->size = intval($size);
        if ($this->size > 512 || $this->size < 0) {
            throw new InvalidArgumentException('Avatar size must be within 0 pixels and 512 pixels');
        }
        return $this;
    }
594629
public function setSize($iSize = null)
    {
        if (null === $iSize) {
            return $this;
        }

        $iSize = intval($iSize);

        if ($iSize < 0 || $iSize > 2048) {
            throw new InvalidImageSizeException('Avatar size must be within 0 pixels and 2048 pixels');
        }

        $this->iSize = $iSize;

        return $this;
    }
73696
public static function ExtendOptions(array $options = [])
    {
        $options = array_merge( [
            'width'=>null,
            'height'=>null,

            'focusX'=>0,
            'focusY'=>0,

            'resize'=>false,
        ], $options );

        // Format to strings
        $options['width'] = $options['width'] ?: '_';
        $options['height'] = $options['height'] ?: '_';

        return $options;
    }
1062105
public function scaleFixedHeight($height)
    {
        $_width = $this->do_getWidth();
        $_height = $this->do_getHeight();

        $width = (int)($_width * $height / $_height);
        $this->do_resize($width, $height);

        return $this;
    }
1357284
function assetImageDimensions($height = null, $width = null) {
        $imageDimensions = [];
        if ($height) $imageDimensions['height'] = $height;
        if ($width) $imageDimensions['width'] = $width;
        if (count($imageDimensions)) $this->data['assetImageDimensions'] = $imageDimensions;
        return $this;
    }
973922
public function resize($width, $height)
    {

        $new = imagecreatetruecolor($width, $height);
        imagealphablending($new, false);
        imagesavealpha($new, true);
        imagecopyresampled($new, $this->image, 0, 0, 0, 0, $width, $height, $this->width, $this->height);

        $this->width = $width;
        $this->height = $height;
        $this->image = $new;

        return $this;

    }
767615
protected function setProperties($percentage)
    {
        if ($percentage > 1) {
            throw new \InvalidArgumentException('$percentage must be less than 1');
        }

        $this->sourceImageHeight = $this->sourceImage->getHeight();
        $this->sourceImageWidth = $this->sourceImage->getWidth();

        $this->mergeImageHeight = $this->mergeImage->getHeight();
        $this->mergeImageWidth = $this->mergeImage->getWidth();

        $this->calculateOverlap($percentage);
        $this->calculateCenter();
    }