Resize an image

@param string $image
@param int|null $width
@param int|null $height
@param array $options
@return string
185618
public function resize($image, $width = null, $height = null, $options = [])
    {
        if (!$this->fileExists($image)) {
            return $this->getMediaImageUrl($image);
        }
        
        $resizedImage = 'resized/' . $width . 'x' . $height . '/' . $image;
        if (!$this->fileExists($resizedImage)) {
            $imageResize = $this->setup($image, $width, $height, $options);
            $imageResize->resize($width, $height);
            $imageResize->save($this->getMediaDirectory()->getAbsolutePath($resizedImage));
        }
        
        return $this->getMediaImageUrl($resizedImage);
    }
1057845
public function resize($width, $height)
    {
        return $this->createCloneWithResource(
            function (InterventionImage $resource) use ($width, $height) {
                return $resource->resize($width, $height);
            }
        );
    }
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);
    }
452500
public function resize($width, $height, Closure $callback = null)
    {
        if (is_null($width) && is_null($height)) {
            throw new \Intervention\Image\Exception\InvalidArgumentException(
                "Width or height needs to be defined."
            );
        }

        // new size with dominant width
        $dominant_w_size = clone $this;
        $dominant_w_size->resizeHeight($height, $callback);
        $dominant_w_size->resizeWidth($width, $callback);

        // new size with dominant height
        $dominant_h_size = clone $this;
        $dominant_h_size->resizeWidth($width, $callback);
        $dominant_h_size->resizeHeight($height, $callback);

        // decide which size to use
        if ($dominant_h_size->fitsInto(new self($width, $height))) {
            $this->set($dominant_h_size->width, $dominant_h_size->height);
        } else {
            $this->set($dominant_w_size->width, $dominant_w_size->height);
        }

        return $this;
    }
1094941
protected function thumbnailResize(Image $image, $width, $height)
    {
        return $image->resize($width, $height, function ($constraint) {
            $constraint->aspectRatio();
        });
    }
1114067
public static function resizeImg($image, $width, $height = 0)
    {
        $newImg = self::getImg($image, $width, $height, false, ManipulatorInterface::THUMBNAIL_OUTBOUND);

        if(self::copyImg($newImg, $image)){
            File::delFile($newImg);
        }
    }
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;
	}
914723
public function runFillResize($image, $width, $height)
    {
        $image = $this->runMaxResize($image, $width, $height);

        return $image->resizeCanvas($width, $height, 'center');
    }
3623
public function limitImageSize($width, $height)
    {
        if ($this->maxImageSize !== null) {
            $imageSize = $width * $height;

            if ($imageSize > $this->maxImageSize) {
                $width = $width / sqrt($imageSize / $this->maxImageSize);
                $height = $height / sqrt($imageSize / $this->maxImageSize);
            }
        }

        return [
            (int) $width,
            (int) $height,
        ];
    }
1216151
public function resize($width, $height)
    {
        $width = (int)$width;
        $height = (int)$height;
        $tmpImage = imagecreatetruecolor($width, $height);
        imagefilledrectangle($tmpImage, 0, 0, $width, $height, $this->backgroundColor);
        imagecopyresampled($tmpImage, $this->resource, 0, 0, 0, 0, $width, $height, $this->width, $this->height);
        $this->width = $width;
        $this->height = $height;
        $this->resource = $tmpImage;
    }
946516
protected function resizeCrop($file, $width, $height)
  	{
		$image = $this->imagine->open($file->getRealPath());
		list($optimalWidth, $optimalHeight) = $this->getOptimalCrop($image->getSize(), $width, $height);

    	// Find center - this will be used for the crop
		$centerX = ($optimalWidth / 2) - ($width / 2);
    	$centerY = ($optimalHeight / 2) - ($height / 2);

		return $image->resize(new Box($optimalWidth, $optimalHeight))
			->crop(new Point($centerX, $centerY), new Box($width, $height));
	}
641279
protected function resizeAuto($file, $width, $height)
	{
		// Image to be resized is wider (landscape)
		if ($height < $width) {
			return $this->resizeLandscape($file, $width, $height);

		}

		// Image to be resized is taller (portrait)
		if ($height > $width){
			return $this->resizePortrait($file, $width, $height);
		}

		// Image to be resizerd is a square
		return $this->resizeExact($file, $width, $height);
	}
825914
public function getImageResized($width = null, $height = null, $method = null)
    {
        if ($this->hasImage()) {
            
            $image = $this->getSlideImage();
            
            if ($width || $height || $method) {
                return ImageTools::singleton()->resize($image, $width, $height, $method);
            }
            
            if ($this->getParent()->hasMethod('performImageResize')) {
                return $this->getParent()->performImageResize($image);
            }
            
            return $image;
            
        }
    }
753207
public function productDeleteByImage($image, $options=array()){

        $data = array();
        
        $data['image'] = base64_encode($image);

        $data = array_merge($data, $options);

        return $this->request($this->productDeleteUrl, $data);
    }
126235
public function resize($width = null, $height = null)
    {
        //argument test
        Argument::i()
            //Argument 1 must be a number or null
            ->test(1, 'numeric', 'null')
            //Argument 2 must be a number or null
            ->test(2, 'numeric', 'null');

        //get the source width and height
        $orgWidth = imagesx($this->resource);
        $orgHeight = imagesy($this->resource);

        //set the width if none is defined
        if (is_null($width)) {
            $width = $orgWidth;
        }

        //set the height if none is defined
        if (is_null($height)) {
            $height = $orgHeight;
        }

        //if the width and height are the same as the originals
        if ($width == $orgWidth && $height == $orgHeight) {
            //there's no need to process
            return $this;
        }

        $newWidth = $width;
        $newHeight = $height;

        //if the desired height is larger than the desired width
        if ($height < $width) {
            //get the width aspect ratio
            $width = $this->getWidthAspectRatio($orgWidth, $orgHeight, $height);
            //if the aspect width is bigger than the desired width
            if ($newWidth < $width) {
                //set it back to the desired width
                $width = $newWidth;
                //and adjust the height instead
                $height = $this->getHeightAspectRatio($orgWidth, $orgHeight, $width);
            }
        //if the desired height is smaller than the desired width
        } else {
            //get the width aspect ratio
            $height = $this->getHeightAspectRatio($orgWidth, $orgHeight, $width);
            //if the aspect height is bigger than the desired height
            if ($newHeight < $height) {
                //set it back to the desired height
                $height = $newHeight;
                //and adjust the width instead
                $width = $this->getWidthAspectRatio($orgWidth, $orgHeight, $height);
            }
        }

        return $this->scale($width, $height);
    }
542913
public function resizeTo(
        int $width,
        int $height,
        bool $maintain_aspect = true,
        array $canvas_color = array('r' => 255, 'g' => 255, 'b' => 255)
    ) : ImageResize
    {
        if ($this->resizer !== null) {
            try {
                $this->resizer->setOptions($width, $height, $this->quality, $maintain_aspect, $canvas_color);
            } catch (\Exception $e) {
                echo $e->getMessage();
            }
        }

        return $this;
    }
1259495
private function actionResize($width, $height)
    {
        $image = $this->getPhpThumb();
        $image->resize($width, $height);
    }