/** * 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; }