core-bundle/src/Image/LegacyResizer.php
public function resize(ImageInterface $image, ResizeConfigurationInterface $config, ResizeOptionsInterface $options): ImageInterface
    {
        $rootDir = System::getContainer()->getParameter('kernel.project_dir');

        if ($this->hasExecuteResizeHook() || $this->hasGetImageHook()) {
            @trigger_error('Using the executeResize and getImage hooks has been deprecated and will no longer work in Contao 5.0. Replace the contao.image.resizer service instead.', E_USER_DEPRECATED);

            $this->legacyImage = null;
            $legacyPath = $image->getPath();

            if (0 === strpos($legacyPath, $rootDir.'/') || 0 === strpos($legacyPath, $rootDir.'\\')) {
                $legacyPath = substr($legacyPath, \strlen($rootDir) + 1);
                $this->legacyImage = new LegacyImage(new File($legacyPath));
                $this->legacyImage->setTargetWidth($config->getWidth());
                $this->legacyImage->setTargetHeight($config->getHeight());
                $this->legacyImage->setResizeMode($config->getMode());
                $this->legacyImage->setZoomLevel($config->getZoomLevel());

                if (
                    ($targetPath = $options->getTargetPath())
                    && (0 === strpos($targetPath, $rootDir.'/') || 0 === strpos($targetPath, $rootDir.'\\'))
                ) {
                    $this->legacyImage->setTargetPath(substr($targetPath, \strlen($rootDir) + 1));
                }

                $importantPart = $image->getImportantPart();

                $this->legacyImage->setImportantPart([
                    'x' => $importantPart->getPosition()->getX(),
                    'y' => $importantPart->getPosition()->getY(),
                    'width' => $importantPart->getSize()->getWidth(),
                    'height' => $importantPart->getSize()->getHeight(),
                ]);
            }
        }

        if ($this->legacyImage && $this->hasExecuteResizeHook()) {
            foreach ($GLOBALS['TL_HOOKS']['executeResize'] as $callback) {
                $return = System::importStatic($callback[0])->{$callback[1]}($this->legacyImage);

                if (\is_string($return)) {
                    return $this->createImage($image, $rootDir.'/'.$return);
                }
            }
        }

        return parent::resize($image, $config, $options);
    }
public function resize(ImageInterface $image, ResizeConfigurationInterface $config, ResizeOptionsInterface $options): ImageInterface
    {
        $rootDir = System::getContainer()->getParameter('kernel.project_dir');

        if ($this->hasExecuteResizeHook() || $this->hasGetImageHook()) {
            @trigger_error('Using the executeResize and getImage hooks has been deprecated and will no longer work in Contao 5.0. Replace the contao.image.resizer service instead.', E_USER_DEPRECATED);

            $this->legacyImage = null;
            $legacyPath = $image->getPath();

            if (0 === strpos($legacyPath, $rootDir.'/') || 0 === strpos($legacyPath, $rootDir.'\\')) {
                $legacyPath = substr($legacyPath, \strlen($rootDir) + 1);
                $this->legacyImage = new LegacyImage(new File($legacyPath));
                $this->legacyImage->setTargetWidth($config->getWidth());
                $this->legacyImage->setTargetHeight($config->getHeight());
                $this->legacyImage->setResizeMode($config->getMode());
                $this->legacyImage->setZoomLevel($config->getZoomLevel());

                if (
                    ($targetPath = $options->getTargetPath())
                    && (0 === strpos($targetPath, $rootDir.'/') || 0 === strpos($targetPath, $rootDir.'\\'))
                ) {
                    $this->legacyImage->setTargetPath(substr($targetPath, \strlen($rootDir) + 1));
                }

                $importantPart = $image->getImportantPart();

                $this->legacyImage->setImportantPart([
                    'x' => $importantPart->getPosition()->getX(),
                    'y' => $importantPart->getPosition()->getY(),
                    'width' => $importantPart->getSize()->getWidth(),
                    'height' => $importantPart->getSize()->getHeight(),
                ]);
            }
        }

        if ($this->legacyImage && $this->hasExecuteResizeHook()) {
            foreach ($GLOBALS['TL_HOOKS']['executeResize'] as $callback) {
                $return = System::importStatic($callback[0])->{$callback[1]}($this->legacyImage);

                if (\is_string($return)) {
                    return $this->createImage($image, $rootDir.'/'.$return);
                }
            }
        }

        return parent::resize($image, $config, $options);
    }
{@inheritdoc}