crop() public method

Vanilla Cropping - Crops from x,y with specified width and height
public crop ( integer $startX, integer $startY, integer $cropWidth, integer $cropHeight ) : GdThumb
$startX integer
$startY integer
$cropWidth integer
$cropHeight integer
return GdThumb
示例#1
0
文件: Image.php 项目: bkwld/croppa
 /**
  * Trim the source before applying the crop with offset percentages
  *
  * @param  array $coords Cropping instructions as percentages
  * @return $this
  */
 public function trimPerc($coords)
 {
     list($x1, $y1, $x2, $y2) = $coords;
     $size = (object) $this->thumb->getCurrentDimensions();
     // Convert percentage values to what GdThumb expects
     $x = round($x1 * $size->width);
     $y = round($y1 * $size->height);
     $width = round($x2 * $size->width - $x);
     $height = round($y2 * $size->height - $y);
     $this->thumb->crop($x, $y, $width, $height);
     return $this;
 }