public function getImportantPartFromLegacyMode(ImageInterface $image, $mode): ImportantPartInterface
    {
        if (1 !== substr_count($mode, '_')) {
            throw new \InvalidArgumentException(sprintf('"%s" is not a legacy resize mode', $mode));
        }

        $importantPart = [
            0,
            0,
            $image->getDimensions()->getSize()->getWidth(),
            $image->getDimensions()->getSize()->getHeight(),
        ];

        [$modeX, $modeY] = explode('_', $mode);

        if ('left' === $modeX) {
            $importantPart[2] = 1;
        } elseif ('right' === $modeX) {
            $importantPart[0] = $importantPart[2] - 1;
            $importantPart[2] = 1;
        }

        if ('top' === $modeY) {
            $importantPart[3] = 1;
        } elseif ('bottom' === $modeY) {
            $importantPart[1] = $importantPart[3] - 1;
            $importantPart[3] = 1;
        }

        return new ImportantPart(
            new Point($importantPart[0], $importantPart[1]),
            new Box($importantPart[2], $importantPart[3])
        );
    }
public function getImportantPartFromLegacyMode(ImageInterface $image, $mode): ImportantPartInterface
    {
        if (1 !== substr_count($mode, '_')) {
            throw new \InvalidArgumentException(sprintf('"%s" is not a legacy resize mode', $mode));
        }

        $importantPart = [
            0,
            0,
            $image->getDimensions()->getSize()->getWidth(),
            $image->getDimensions()->getSize()->getHeight(),
        ];

        [$modeX, $modeY] = explode('_', $mode);

        if ('left' === $modeX) {
            $importantPart[2] = 1;
        } elseif ('right' === $modeX) {
            $importantPart[0] = $importantPart[2] - 1;
            $importantPart[2] = 1;
        }

        if ('top' === $modeY) {
            $importantPart[3] = 1;
        } elseif ('bottom' === $modeY) {
            $importantPart[1] = $importantPart[3] - 1;
            $importantPart[3] = 1;
        }

        return new ImportantPart(
            new Point($importantPart[0], $importantPart[1]),
            new Box($importantPart[2], $importantPart[3])
        );
    }
public function getImportantPartFromLegacyMode ( ImageInterface $ image , $ mode ) : ImportantPartInterface { if ( 1 !== substr_count ( $ mode , '_' ) ) { throw new \ InvalidArgumentException ( sprintf ( '"%s" is not a legacy resize mode' , $ mode ) ) ; } $ importantPart = [ 0 , 0 , $ image -> getDimensions ( ) -> getSize ( ) -> getWidth ( ) , $ image -> getDimensions ( ) -> getSize ( ) -> getHeight ( ) , ] ; [ $ modeX , $ modeY ] = explode ( '_' , $ mode ) ; if ( 'left' === $ modeX ) { $ importantPart [ 2 ] = 1 ; } elseif ( 'right' === $ modeX ) { $ importantPart [ 0 ] = $ importantPart [ 2 ] - 1 ; $ importantPart [ 2 ] = 1 ; } if ( 'top' === $ modeY ) { $ importantPart [ 3 ] = 1 ; } elseif ( 'bottom' === $ modeY ) { $ importantPart [ 1 ] = $ importantPart [ 3 ] - 1 ; $ importantPart [ 3 ] = 1 ; } return new ImportantPart ( new Point ( $ importantPart [ 0 ] , $ importantPart [ 1 ] ) , new Box ( $ importantPart [ 2 ] , $ importantPart [ 3 ] ) ) ; }
{@inheritdoc}
{