Deletes a piece of image from specific side.
For example, if side=top and size=100, 100px from top will be deleted.
@param string $side Side to cut
@param int $size Pixels
@return ImageEditor this object
9297
public function decreaseSide($side, $size) {
		$x = $y = 1;
		$x2 = $this->width;
		$y2 = $this->height;
		switch ($side) {
			case 'top':
				$y = $size;
				break;
			case 'right':
				$x2 -= $size;
				break;
			case 'bottom':
				$y2 -= $size;
				break;
			case 'left':
				$x = $size;
				break;
		}
		$this->crop($x, $y, $x2, $y2);
		return $this;
	}
114268
public function setSlice( $start, $size = 100 )
	{
		$this->_sliceStart = (int) $start;
		$this->_sliceSize = (int) $size;

		return $this;
	}
576897
public function crop($width, $height, $x_pos = null, $y_pos = null): ImageEditingInterface
    {
        $this->image->crop($width, $height, $x_pos, $y_pos);

        return $this;
    }
906876
final public function resizeImage($width = null, $height = null)
	{
		if (is_int($width) and is_int($height)) {
			$new_image = imagecreatetruecolor($width, $height);
			imagecopyresampled(
				$new_image,
				$this->_image_handle,
				0,
				0,
				0,
				0,
				$width,
				$height,
				$this->imageWidth(),
				$this->imageHeight()
			);
			if (is_resource($new_image)) {
				$this->_image_handle = $new_image;
			}
		}
		return $this;
	}
902779
public function truncate($size)
    {
        if($resource = $this->getResource())
        {
            if($this->isWritable()) {
                return @ftruncate($resource, $size);
            }
        }

        return false;
    }
589840
protected static function prepareSize($size, array $definition)
	{
		$css = sprintf('col-%s-%s', $size, $definition['width']);

		if($definition['offset']) {
			$css .= sprintf(' col-%s-offset-%s', $size, $definition['offset']);
		}

		if($definition['order']) {
			$css .= sprintf(' col-%s-%s', $size, $definition['order']);
		}

		return $css;
	}
507478
public function do_resize($width, $height)
    {
        if (version_compare(PHP_VERSION, '5.5.0') < 0) {
            $image = imagecreatetruecolor($width, $height);
            imagealphablending($image, false);
            imagesavealpha($image, true);

            imagecopyresampled($image, $this->_image, 0, 0, 0, 0, $width, $height, $this->_width, $this->_height);
        } else {
            $image = imagescale($this->_image, $width, $height);
        }

        imagedestroy($this->_image);
        $this->_image = $image;
        $this->_width = imagesx($image);
        $this->_height = imagesy($image);

        return $this;
    }
41485
public function do_crop($width, $height, $offsetX = 0, $offsetY = 0)
    {
        if (version_compare(PHP_VERSION, '5.5.0') < 0) {
            $image = imagecreatetruecolor($width, $height);
            imagealphablending($image, false);
            imagesavealpha($image, true);
            imagecopy($image, $this->_image, 0, 0, $offsetX, $offsetY, $width, $height);
        } else {
            $rect = ['x' => $offsetX, 'y' => $offsetY, 'width' => $width, 'height' => $height];
            $image = imagecrop($this->_image, $rect);
        }

        imagedestroy($this->_image);
        $this->_image = $image;
        $this->_width = imagesx($image);
        $this->_height = imagesy($image);

        return $this;
    }
1369614
public function getImageSrc($size = null)
    {
        $owner = $this->owner;

        $prefix = '';
        if (Yii::$app->request instanceof \yii\web\Request) {
            $prefix = Yii::$app->request->baseUrl;
            $host = Yii::$app->request->hostInfo;
            // If current application is backend - return absolute frontend image path
            if (!empty($this->_backendSubdomain) && strpos($host, $this->_backendSubdomain) !== false) {
                $prefix = str_replace($this->_backendSubdomain, '', $host) . $prefix;
            }
            if (!empty($this->_backendRoute) && strpos($prefix, $this->_backendRoute) !== false) {
                $prefix = str_replace($this->_backendRoute, '', $prefix);
            }
        }

        $image = $owner->{$this->_imageAttribute};
        if (empty($image)) {
            if (isset($this->getImageSizes()[$size])) {
                return $prefix . '/images/' . static::addPrefixToFile($this->_noImageBaseName, $size);
            }

            return $prefix . '/images/' . $this->_noImageBaseName;
        }

        $root = Yii::getAlias($this->_rootPathAlias); // Webroot
        $path = Yii::getAlias($this->_savePathAlias); // Uploading dir
        $path = str_replace($root, '', $path); // Remove server path
        $path = str_replace('\\', '/', $path); // Replace "\" to "/"
        $folder = $prefix . '/' . trim($path, '/') . '/';

        if (!empty($size)) {
            return $folder . static::addPrefixToFile($image, $size);
        } else {
            return $folder . $image;
        }
    }
946435
public function crop($image, $width, $height, $options = [])
    {
        if (!$this->fileExists($image)) {
            return $this->getMediaImageUrl($image);
        }

        $croppedImage = 'cropped/' . $width . 'x' . $height . '/' . $image;
        if (!$this->fileExists($croppedImage)) {
            $imageCrop = $this->setup($image, $width, $height, array_merge($options, ['constrainOnly' => false, 'keepAspectRatio' => true, 'keepFrame' => false]));
            
            $originalAspectRatio = $imageCrop->getOriginalWidth() / $imageCrop->getOriginalHeight();
            $aspectRatio = $width / $height;
            
            if ($aspectRatio < $originalAspectRatio) {
                $cropWidth = ceil($height * $originalAspectRatio);
                $cropHorizontal = ($cropWidth - $width) / 2;
                $imageCrop->resize($cropWidth, $height);
                $imageCrop->crop(0, $cropHorizontal, $cropHorizontal, 0);
            } else {
                $cropHeight = ceil($width / $originalAspectRatio);
                $cropVertical = ($cropHeight - $height) / 2;
                $imageCrop->resize($width, $cropHeight);
                $imageCrop->crop($cropVertical, 0, 0, $cropVertical);
            }
            
            $imageCrop->save($this->getMediaDirectory()->getAbsolutePath($croppedImage));
        }
        
        return $this->getMediaImageUrl($croppedImage);
    }
47058
private function _getImageToSize(array $images, int $size)
	{
		$selectedImage = null;
		$selectedSize = 0;

		foreach ($images as $image)
		{
			if (is_array($image))
			{
				$imageWidth = isset($image['width']) && is_numeric($image['width']) ? $image['width'] : 0;
				$imageHeight = isset($image['height']) && is_numeric($image['height']) ? $image['height'] : 0;
				$imageSize = max($imageWidth, $imageHeight);

				if (!$selectedImage ||
					($selectedSize < $size && $imageSize > $selectedSize) ||
					($selectedSize > $imageSize && $imageSize > $size))
				{
					$selectedImage = $image;
					$selectedSize = $imageSize;
				}
			}
		}

		return $selectedImage;
	}
597573
public function resize($img, $size)
    {
        $curSize = imagesx($img);
        if ($curSize == $size) {
            return $img;
        }

        $newImg = imagecreatetruecolor($size, $size);
        imagecopyresampled($newImg, $img, 0, 0, 0, 0, $size, $size, $curSize, $curSize);

        return $newImg;
    }
1171047
public function freecrop($width, $height, $x = false, $y = false)
    {
        if ($x === false || $y === false) {
            return $this->crop($width, $height);
        }
        $this->source_x = $x;
        $this->source_y = $y;
        if ($width > $this->getSourceWidth() - $x) {
            $this->source_w = $this->getSourceWidth() - $x;
        } else {
            $this->source_w = $width;
        }

        if ($height > $this->getSourceHeight() - $y) {
            $this->source_h = $this->getSourceHeight() - $y;
        } else {
            $this->source_h = $height;
        }

        $this->dest_w = $width;
        $this->dest_h = $height;

        return $this;
    }
1304330
public function setWatermarkSize($size)
    {
        if (is_array($size)) {
            $this->setWatermarkWidth($size['width'])->setWatermarkHeight($size['height']);
        }
        return $this;
    }
220600
public function imageDownsize($fail, $id, $size) {
        if ($this->skipGifs) {
            $mimeType = get_post_mime_type($id);
            if ($mimeType == 'image/gif') {
                /** @var StorageTool $storageTool */
                $storageTool = ToolsManager::instance()->tools['storage'];

                $result = $storageTool->forcedImageDownsize($fail, $id, $size);
                return $result;
            }
        }

		$result = $this->buildImgixImage($id, $size);

		return $result;
	}
545818
public function divide(Size $size): Size
    {
        if (0 === $size->get('b')) {
            throw new \OutOfBoundsException('Could not divide by zero.');
        }

        $this->bit = \ceil($this->bit / $size->get('b'));

        return $this;
    }
1270933
public function setControlSize(string $size)
    {
        $allowed_sizes = [
            'lg',
            'md',
            'sm',
            'xs'
        ];

        if (!in_array($size, $allowed_sizes)) {
            Throw new FormDesignerException(sprintf('Size "%s" is no valid controlsize. Allowed sizes are %s.', $size, implode(', ', $allowed_sizes)));
        }

        $this->control_size = $size;
    }