function crop($left, $top, $width, $height) { if ($this->file === NULL) { return parent::crop($left, $top, $width, $height); } list($left, $top, $width, $height) = self::calculateCutout($this->getWidth(), $this->getHeight(), $left, $top, $width, $height); $this->execute("convert -crop {$width}x{$height}+{$left}+{$top} -strip %input %output", self::PNG); return $this; }
function crop($left, $top, $width, $height) { if ($this->file === NULL) { return parent::crop($left, $top, $width, $height); } $left = max(0, (int) $left); $top = max(0, (int) $top); $width = min((int) $width, $this->getWidth() - $left); $height = min((int) $height, $this->getHeight() - $top); $this->execute("convert -crop {$width}x{$height}+{$left}+{$top} -strip %input %output", self::PNG); return $this; }