protected function imgCrop($path, $width, $height, $x, $y, $destformat = null)
{
if (($s = @getimagesize($path)) == false) {
return false;
}
$result = false;
switch ($this->imgLib) {
case 'imagick':
try {
$img = new imagick($path);
} catch (Exception $e) {
return false;
}
$img->cropImage($width, $height, $x, $y);
$result = $img->writeImage($path);
return $result ? $path : false;
break;
case 'gd':
$img = self::gdImageCreate($path, $s['mime']);
if ($img && false != ($tmp = imagecreatetruecolor($width, $height))) {
self::gdImageBackground($tmp, $this->options['tmbBgColor']);
$size_w = $width;
$size_h = $height;
if ($s[0] < $width || $s[1] < $height) {
$size_w = $s[0];
$size_h = $s[1];
}
if (!imagecopy($tmp, $img, 0, 0, $x, $y, $size_w, $size_h)) {
return false;
}
$result = self::gdImage($tmp, $path, $destformat, $s['mime']);
imagedestroy($img);
imagedestroy($tmp);
return $result ? $path : false;
}
break;
}
return false;
}