function crop($iScaledWidth, $iScaledHeight, $x, $y, $iCroppedWidth, $iCroppedHeight, $iRotation, $sSrcImage, $sDstImage = '')
{
$iScaledWidth = round($iScaledWidth);
$iScaledHeight = round($iScaledHeight);
$this->_sError = '';
try {
$o = $this->_oManager->make($sSrcImage)->resize($iScaledWidth, $iScaledHeight)->rotate($iRotation);
$iImgRotWidth = $o->width();
$iImgRotHeight = $o->height();
$dx = round(($iImgRotWidth - $iScaledWidth) / 2);
$dy = round(($iImgRotHeight - $iScaledHeight) / 2);
$o->crop($iScaledWidth, $iScaledHeight, $dx, $dy)->crop(round($iCroppedWidth), round($iCroppedHeight), $x, $y)->save($sDstImage ? $sDstImage : $sSrcImage, $this->_iJpegQuality);
} catch (Exception $e) {
$this->_sError = $e->getMessage();
return IMAGE_ERROR_WRONG_TYPE;
}
return IMAGE_ERROR_SUCCESS;
}