Contao\Image::prepareImportantPart PHP Method

prepareImportantPart() protected method

Prepare important part object.
protected prepareImportantPart ( ) : Contao\Image\ImportantPart
return Contao\Image\ImportantPart
    protected function prepareImportantPart()
    {
        $importantPart = $this->getImportantPart();
        if (substr_count($this->resizeMode, '_') === 1) {
            $importantPart = array('x' => 0, 'y' => 0, 'width' => $this->fileObj->viewWidth, 'height' => $this->fileObj->viewHeight);
            $mode = explode('_', $this->resizeMode);
            if ($mode[0] === 'left') {
                $importantPart['width'] = 1;
            } elseif ($mode[0] === 'right') {
                $importantPart['x'] = $importantPart['width'] - 1;
                $importantPart['width'] = 1;
            }
            if ($mode[1] === 'top') {
                $importantPart['height'] = 1;
            } elseif ($mode[1] === 'bottom') {
                $importantPart['y'] = $importantPart['height'] - 1;
                $importantPart['height'] = 1;
            }
        }
        if (!$importantPart['width'] || !$importantPart['height']) {
            return null;
        }
        return new ImportantPart(new Point($importantPart['x'], $importantPart['y']), new Box($importantPart['width'], $importantPart['height']));
    }