public function cropFromCenter($cropWidth, $cropHeight = null)
{
if (!is_numeric($cropWidth)) {
throw new InvalidArgumentException('$cropWidth must be numeric');
}
if ($cropHeight !== null && !is_numeric($cropHeight)) {
throw new InvalidArgumentException('$cropHeight must be numeric');
}
if ($cropHeight === null) {
$cropHeight = $cropWidth;
}
$cropWidth = $this->currentDimensions['width'] < $cropWidth ? $this->currentDimensions['width'] : $cropWidth;
$cropHeight = $this->currentDimensions['height'] < $cropHeight ? $this->currentDimensions['height'] : $cropHeight;
$cropX = intval(($this->currentDimensions['width'] - $cropWidth) / 2);
$cropY = intval(($this->currentDimensions['height'] - $cropHeight) / 2);
$this->crop($cropX, $cropY, $cropWidth, $cropHeight);
return $this;
}