public function crop($left, $top, $right, $bottom)
{
$left = VarFilter::int($left);
$top = VarFilter::int($top);
$right = VarFilter::int($right);
$bottom = VarFilter::int($bottom);
// Determine crop size
if ($right < $left) {
list($left, $right) = array($right, $left);
}
if ($bottom < $top) {
list($top, $bottom) = array($bottom, $top);
}
$cropedW = $right - $left;
$cropedH = $bottom - $top;
// Perform crop
$newImage = imagecreatetruecolor($cropedW, $cropedH);
Helper::addAlpha($newImage);
imagecopyresampled($newImage, $this->_image, 0, 0, $left, $top, $cropedW, $cropedH, $cropedW, $cropedH);
// Update meta data
$this->_replaceImage($newImage);
$this->_width = $cropedW;
$this->_height = $cropedH;
return $this;
}