public function resize($hash, $width, $height, $x, $y, $mode = 'resize', $bg = '', $degree = 0)
{
if ($this->commandDisabled('resize')) {
return $this->setError(elFinder::ERROR_PERM_DENIED);
}
if (($file = $this->file($hash)) == false) {
return $this->setError(elFinder::ERROR_FILE_NOT_FOUND);
}
if (!$file['write'] || !$file['read']) {
return $this->setError(elFinder::ERROR_PERM_DENIED);
}
$path = $this->decode($hash);
if (!$this->canResize($path, $file)) {
return $this->setError(elFinder::ERROR_UNSUPPORT_TYPE);
}
switch ($mode) {
case 'propresize':
$result = $this->imgResize($path, $width, $height, true, true);
break;
case 'crop':
$result = $this->imgCrop($path, $width, $height, $x, $y);
break;
case 'fitsquare':
$result = $this->imgSquareFit($path, $width, $height, 'center', 'middle', $bg ? $bg : $this->options['tmbBgColor']);
break;
case 'rotate':
$result = $this->imgRotate($path, $degree, $bg ? $bg : $this->options['tmbBgColor']);
break;
default:
$result = $this->imgResize($path, $width, $height, false, true);
break;
}
if ($result) {
$this->rmTmb($file);
$this->clearcache();
return $this->stat($path);
}
return false;
}