elFinder\elFinderVolumeDriver::resize PHP Метод

resize() публичный Метод

Resize image
Автор: Dmitry (dio) Levashov
Автор: Alexey Sukhotin
Автор: nao-pon
Автор: Troex Nevelin
public resize ( string $hash, integer $width, integer $height, integer $x, integer $y, string $mode = 'resize', $bg = '', $degree ) : array | false
$hash string image file
$width integer new width
$height integer new height
$x integer X start poistion for crop
$y integer Y start poistion for crop
$mode string action how to mainpulate image
Результат array | false
    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;
    }