裁剪图片,如果不传入$startX, $startY, 则默认从图片正中间开始裁剪
@param int $width 裁剪高度
@param int $height 裁剪宽度
@param int $startX 裁剪起始位置横坐标
@param int $startY 裁剪起始位置纵坐标
@return $this
278
public function crop($width, $height, $startX=null, $startY=null)
    {
        $sizeSrc = $this->getImageSize($this->imgSrc);
        if ( $startX === null ) {
            $startX = ($sizeSrc[0] - $width)/2;
        }
        if ( $startY === null ) {
            $startY = ($sizeSrc[1] - $height)/2;
        }
        $this->imgDst = imagecrop($this->imgDst,
            ['x' => $startX, 'y' => $startY, 'width' => $width, 'height' => $height]);
        return $this;
    }
21016
public function newImage($width, $height, $background = null)
    {
        $background = new Color($background);

        // create empty core
        $core = new \Imagick;
        $core->newImage($width, $height, $background->getPixel(), 'png');
        $core->setType(\Imagick::IMGTYPE_UNDEFINED);
        $core->setImageType(\Imagick::IMGTYPE_UNDEFINED);
        $core->setColorspace(\Imagick::COLORSPACE_UNDEFINED);

        // build image
        return new Image(new static, $core);
    }
1002348
protected function calcImageSize($width, $height)
    {
        $newSize = array(
            'newWidth' => $width,
            'newHeight' => $height
        );

        if ($this->maxWidth > 0) {
            $newSize = $this->calcWidth($width, $height);

            if ($this->maxHeight > 0 && $newSize['newHeight'] > $this->maxHeight) {
                $newSize = $this->calcHeight($newSize['newWidth'], $newSize['newHeight']);
            }
        }

        if ($this->maxHeight > 0) {
            $newSize = $this->calcHeight($width, $height);

            if ($this->maxWidth > 0 && $newSize['newWidth'] > $this->maxWidth) {
                $newSize = $this->calcWidth($newSize['newWidth'], $newSize['newHeight']);
            }
        }

        $this->newDimensions = $newSize;
    }
790985
public function setSize($width, $height)
    {
        $params = [
            'width' => intval($width),
            'height' => intval($height)
        ];
        $command = $this->driver->factoryCommand(
            'window/' . $this->windowHandle . '/size',
            WebDriver_Command::METHOD_POST,
            $params
        );
        return $this->driver->curl($command)['value'];
    }
1072018
public function resize($width, $height) {

        $new = @imagecreatetruecolor($width, $height);

        // This needed to deal with .png transparency
        imagealphablending($new, false);
        imagesavealpha($new, true);
        $transparent = imagecolorallocatealpha($new, 255, 255, 255, 127);
        imagefilledrectangle($new, 0, 0, $width, $height, $transparent);

        imagecopyresampled($new, $this->resource, 0, 0, 0, 0, $width, $height,
            $this->width(), $this->height());
        $this->resource = $new;

        // for method chaining
        return $this;
    }
814618
private function simpleCrop($width, $height) {
        $sourceRatio = $this->image->getWidth() / $this->image->getHeight();
        $cropRatio = $width / $height;

        $params = [];

        if ($cropRatio > $sourceRatio) {
            $params['width'] = $width;
        } else {
            $params['height'] = $height;
        }

        $transformationManager = $this->event->getTransformationManager();

        $maxSize = $transformationManager->getTransformation('maxSize');
        $maxSize->setImage($this->image)->transform($params);

        $crop = $transformationManager->getTransformation('crop');
        $crop->setImage($this->image)->transform([
            'width' => $width,
            'height' => $height,
            'mode' => 'center'
        ]);
    }
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;
    }
1317845
public static function rotateX(array &$array, int $distance,
			int $startX = 0, int $startY = 0, int $stopX = null, int $stopY = null)
	{
		self::prepare($array, $stopX, $stopY);
		$rotateLeft = $distance > 0;
		$distance = abs($distance) % ($stopX - $startX);
		$x = $rotateLeft ? $startX + $distance : $stopX - $distance;
		self::reverseX($array, $startX, $startY, $x,     $stopY);
		self::reverseX($array, $x,      $startY, $stopX, $stopY);
		self::reverseX($array, $startX, $startY, $stopX, $stopY);
	}
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;
    }
434439
public function limit($start, $offset = null) {
        $this->_limit = ' LIMIT ' . $start;
        
        if (!is_null($offset)) {
            $this->_limit .= ', ' . $offset;    
        }
        
        return $this;
    }
768524
public function do_crop($width, $height, $offsetX = 0, $offsetY = 0)
    {
        $this->_image->cropImage($width, $height, $offsetX, $offsetY);
        $this->_image->setImagePage($width, $height, 0, 0);

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

        return $this;
    }
602815
public function windowSize($width,$height)
    {
        $this->windowWidth  = $width;
        $this->windowHeight = $height;
        return $this;
    }
383214
protected function doCropResized($width, $height, $x, $y)
  {
    $w = $this->getWidth();
    $h = $this->getHeight();

    if (($h / ($w / $width)) < $height) {
      $this->doResize(null, $height);
    } else {
      $this->doResize($width, null);
    }

    return $this->doCrop($width, $height, $x, $y);
  }
1054838
public function resize($width = 0, $height = 0) 
    {
        if ($width != 0 || $height != 0) {
            $width = $this->getNewWidth($width, $height);
            $height = $this->getNewHeight($width, $height);
        } else {
            $width = $this->imageInfo['width'];
            $height = $this->imageInfo['height'];
        }

        $this->destImageWidth = $width;
        $this->destImageHeight = $height;
        
        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;
    }
83805
public function TransparentPad($width, $height){
			return (($this->owner->getWidth() == $width) &&  ($this->owner->getHeight() == $height)) 
			? $this->owner
			: $this->owner->getTransparentFormattedImage('TransparentPad', $width, $height);
		}
1366106
public function scaleTo($width=null, $height=null)
    {
        if (!$width && !$height) {
            throw new UnderflowException('You have to pass at least width or height.');
        }

        if ($width instanceof Size) {
            return new static($width->width(), $width->height());
        }

        if ($width && $height) {
            return new static($width, $height);
        }

        if (!$width) {
            return new static($height * $this->aspectRatio(), $height);
        }

        return new static($width, $width / $this->aspectRatio());

    }