Crop and resize filter.

@param int $width
@param int $height
@param int $gravity

@access protected
@return void
183987
protected function filterCropScale($gravity)
    {
        $this
            ->resize($this->targetSize['width'], $this->targetSize['height'], static::FL_FILL_AREA)
            ->gravity($gravity)
            ->extent($this->targetSize['width'], $this->targetSize['height']);
    }
1218006
protected function do_resize(\stdClass $src, $width, $height) {

		$dst = new \stdClass();
		$dst->resource	= imagecreatetruecolor($width, $height);
		$dst->width		= $width;
		$dst->height	= $height;

		if($this->mimeType == 'image/png' || $this->mimeType == 'image/gif') {
			imagealphablending($dst->resource, FALSE);
			imagesavealpha($dst->resource, TRUE);
		}

		imagecopyresampled(
			$dst->resource,
			$src->resource,
			0, 0, 0, 0,
			$dst->width, $dst->height,
			$src->width, $src->height
		);
		
		// add some sharpening

		imageconvolution($dst->resource, array(
			array(-1, -0.8, -1),
			array(-0.8, 16, -0.8),
			array(-1, -0.8, -1)
		), 16 - 7.2, 0);

		return $dst;
	}
419610
protected function do_resize(\stdClass $src, $width, $height) {

		$src->resource->resizeImage($width, $height, \Imagick::FILTER_CATROM, 1, FALSE);
		$src->resource->convolveImage([-1, -0.8, -1, -0.8, 16, -0.8, -1, -0.8, -1]);
		
		$src->width		= $width;
		$src->height	= $height;

		return $src;
		
	}
179301
protected function setParameterValues($mode, $width = null, $height = null, $gravity = null, $background = null)
    {
        $parameter = compact('mode', 'width', 'height', 'gravity', 'background');
        $this->parameter = array_merge($this->parameter, $parameter);
    }
993218
public function centerCrop($width, $height)
    {
        $pwidth = $this->getPropWidth($height);
        $pheight = $this->getPropHeight($width);

        if ($pwidth == $width && $pheight == $height) {
            $this->resizeToWidth($width);
        } else {
            if ($pheight > $height) {
                $this->resizeToWidth($width);
            } else {
                $pheight += $height - $pheight;
                $this->resizeToHeight($pheight);
            }

            $x = ($this->width - $width) / 2;
            $y = ($this->height - $height) / 2;
            $this->crop($width, $height, $x, $y);
        }

        return $this;
    }
1052805
public function resize($width, $height = NULL, $resizeMode = NULL)
    {
        if(!$height)
        {
            $height = $width;
        }

        $this->effect[] = new Resize($width, $height, $resizeMode);
    }
564521
public function resize($width, $height) {
        if (!$width) $width = 1;
        if (!$height) $height = 1;
        return (
            (false !== ($img = new gd(array($width, $height)))) &&
            $img->imagecopyresampled($this) &&
            (false !== ($this->image = $img->get_image())) &&
            (false !== ($this->width = $img->get_width())) &&
            (false !== ($this->height = $img->get_height()))
        );
    }
784593
public function setSize($width, $height)
    {
        $this->width = $width;
        $this->height = $height;
        $this->ratioX = $width / $height;
        $this->ratioY = $height / $width;

        return $this;
    }
443343
def crop_resized(image, size, gravity = "Center")
      size =~ /(\d+)x(\d+)/
      width = $1.to_i
      height = $2.to_i

      # Grab the width and height of the current image in one go.
      cols, rows = image[:dimensions]

      # Only do anything if needs be. Who knows, maybe it's already the exact
      # dimensions we're looking for.
      if(width != cols && height != rows)
        image.combine_options do |c|
          # Scale the image down to the widest dimension.
          if(width != cols || height != rows)
            scale = [width / cols.to_f, height / rows.to_f].max * 100
            c.resize("#{scale}%")
          end

          # Align how things will be cropped.
          c.gravity(gravity)

          # Crop the image to size.
          c.crop("#{width}x#{height}+0+0")
        end
      end
    end
919512
public function resizeCropCenter($width, $height)
    {
        $_width = $this->do_getWidth();
        $_height = $this->do_getHeight();

        if ($_width / $_height > $width / $height) {
            $crop_height = $_height;
            $crop_width = $width * $crop_height / $height;
            $offsetX = ($_width - $crop_width) / 2;
            $offsetY = 0;
        } else {
            $crop_width = $_width;
            $crop_height = $height * $crop_width / $width;
            $offsetY = ($_height - $crop_height) / 2;
            $offsetX = 0;
        }

        $this->crop($crop_width, $crop_height, $offsetX, $offsetY);
        $this->scale($width / $crop_width);

        return $this;
    }
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;
    }
800986
public function resize($width, $height) {
		$image = imagecreatetruecolor($width, $height);
		imagealphablending($image, false);
		imagesavealpha($image, true);
		imagecopyresampled($image, $this->_image, 0, 0, 0, 0, $width, $height, $this->width, $this->height);
		imagedestroy($this->_image);
		$this->_image = $image;
		return $this;
	}
119929
public function resizeWindow($width, $height)
    {
        $this->webDriver->manage()->window()->setSize(new WebDriverDimension($width, $height));
    }
229588
public function do_resize($width, $height)
    {
        $this->_image->scaleImage($width, $height);

        $this->_width = $this->_image->getImageWidth();
        $this->_height = $this->_image->getImageHeight();

        return $this;
    }
663138
protected function resize($width, $height, $flag = '')
    {

        switch ($flag) {
            // oversize image to fill the boudaries
            case static::FL_FILL_AREA:
                $this->fillArea($width, $height, $this->getInfo('width'), $this->getInfo('height'));
                break;
            // ignoring aspect ration is default behaviour on imagick resize
            case static::FL_IGNR_ASPR:
                break;
            case static::FL_PIXL_CLMT:
                extract($this->pixelLimit($this->getInfo('width'), $this->getInfo('height'), $width));
                break;
            case static::FL_RESZ_PERC:
                extract($this->percentualScale($this->getInfo('width'), $this->getInfo('height'), $width));
                break;
            // No scaling for larger images.
            // Would be easier to just set `bestfit`, but its behaviour changed
            // with imagemagick 3.0, so we have to calculate the best fit our selfs.
            case static::FL_OSRK_LGR:
                extract($this->fitInBounds($width, $height, $this->getInfo('width'), $this->getInfo('height')));
                break;
            // therefore we set $height always to zero
            default:
                $height = 0;
                break;
        }

        // filter and blur differ for up and downscaling
        if ($width > $this->getInfo('width') or $height > $this->getInfo('height')) {
            $filter = Imagick::FILTER_CUBIC;
            $blur   = 0.6;
        } else {
            $filter = Imagick::FILTER_SINC;
            $blur   = 1;
        }

        $this->resource->resizeImage($width, $height, $filter, $blur);
        return $this;
    }
266936
public function crop(int $width, int $height): self
    {
        $this->image = $this->cropImage($this->image, $width, $height);
        return $this;
    }
941821
public function resize($width, $height, $x = 0, $y = 0)
    {
        if ( !$this->newImage )
        {
            $this->create($width, $height);
        }

        if ( !is_numeric($width) ) {
            throw new \InvalidArgumentException('$width must be numeric');
        }

        if ( !is_numeric($height) ) {
            throw new \InvalidArgumentException('$height must be numeric');
        }

        $type = $this->source['type'];

        imagecopyresampled(
            $this->newImage,
            $this->sourceImage,
            0, 0,
            $x, $y,
            $width, $height,
            $this->source['width'], $this->source['height']);

        return $this;
    }