private function createImportantPart(ImageInterface $image): ?ImportantPart
    {
        /** @var FilesModel $filesModel */
        $filesModel = $this->framework->getAdapter(FilesModel::class);
        $file = $filesModel->findByPath($image->getPath());

        if (null === $file || !$file->importantPartWidth || !$file->importantPartHeight) {
            return null;
        }

        $imageSize = $image->getDimensions()->getSize();

        if (
            $file->importantPartX + $file->importantPartWidth > $imageSize->getWidth()
            || $file->importantPartY + $file->importantPartHeight > $imageSize->getHeight()
        ) {
            return null;
        }

        return new ImportantPart(
            new Point((int) $file->importantPartX, (int) $file->importantPartY),
            new Box((int) $file->importantPartWidth, (int) $file->importantPartHeight)
        );
    }
private function createImportantPart(ImageInterface $image): ?ImportantPart
    {
        
        $filesModel = $this->framework->getAdapter(FilesModel::class);
        $file = $filesModel->findByPath($image->getPath());

        if (null === $file || !$file->importantPartWidth || !$file->importantPartHeight) {
            return null;
        }

        $imageSize = $image->getDimensions()->getSize();

        if (
            $file->importantPartX + $file->importantPartWidth > $imageSize->getWidth()
            || $file->importantPartY + $file->importantPartHeight > $imageSize->getHeight()
        ) {
            return null;
        }

        return new ImportantPart(
            new Point((int) $file->importantPartX, (int) $file->importantPartY),
            new Box((int) $file->importantPartWidth, (int) $file->importantPartHeight)
        );
    }
private function createImportantPart ( ImageInterface $ image ) : ? ImportantPart { /** @var FilesModel $filesModel */ $ filesModel = $ this -> framework -> getAdapter ( FilesModel :: class ) ; $ file = $ filesModel -> findByPath ( $ image -> getPath ( ) ) ; if ( null === $ file || ! $ file -> importantPartWidth || ! $ file -> importantPartHeight ) { return null ; } $ imageSize = $ image -> getDimensions ( ) -> getSize ( ) ; if ( $ file -> importantPartX + $ file -> importantPartWidth > $ imageSize -> getWidth ( ) || $ file -> importantPartY + $ file -> importantPartHeight > $ imageSize -> getHeight ( ) ) { return null ; } return new ImportantPart ( new Point ( ( int ) $ file -> importantPartX , ( int ) $ file -> importantPartY ) , new Box ( ( int ) $ file -> importantPartWidth , ( int ) $ file -> importantPartHeight ) ) ; }
Fetches the important part from the database.
Fetches the important part from the database .