Beispiel #1
0
 /**
  * {@inheritdoc}
  */
 protected function executeResize(ImageInterface $image, ResizeCoordinatesInterface $coordinates, $path, ResizeOptionsInterface $options)
 {
     if (isset($GLOBALS['TL_HOOKS']['getImage']) && is_array($GLOBALS['TL_HOOKS']['getImage']) && $this->legacyImage) {
         foreach ($GLOBALS['TL_HOOKS']['getImage'] as $callback) {
             $return = System::importStatic($callback[0])->{$callback[1]}($this->legacyImage->getOriginalPath(), $this->legacyImage->getTargetWidth(), $this->legacyImage->getTargetHeight(), $this->legacyImage->getResizeMode(), $this->legacyImage->getCacheName(), new File($this->legacyImage->getOriginalPath()), $this->legacyImage->getTargetPath(), $this->legacyImage);
             if (is_string($return)) {
                 return $this->createImage($image, TL_ROOT . '/' . $return);
             }
         }
     }
     if ($image->getImagine() instanceof GdImagine) {
         /** @var Config $config */
         $config = $this->framework->getAdapter(Config::class);
         $dimensions = $image->getDimensions();
         // Return the path to the original image if it cannot be handled
         if ($dimensions->getSize()->getWidth() > $config->get('gdMaxImgWidth') || $dimensions->getSize()->getHeight() > $config->get('gdMaxImgHeight') || $coordinates->getSize()->getWidth() > $config->get('gdMaxImgWidth') || $coordinates->getSize()->getHeight() > $config->get('gdMaxImgHeight')) {
             return $this->createImage($image, $image->getPath());
         }
     }
     return parent::executeResize($image, $coordinates, $path, $options);
 }
Beispiel #2
0
 /**
  * Executes the resize operation via Imagine.
  *
  * @param ImageInterface             $image
  * @param ResizeCoordinatesInterface $coordinates
  * @param string                     $path
  * @param ResizeOptionsInterface     $options
  *
  * @return ImageInterface
  *
  * @internal Do not call this method in your code; it will be made private in a future version
  */
 protected function executeResize(ImageInterface $image, ResizeCoordinatesInterface $coordinates, $path, ResizeOptionsInterface $options)
 {
     if (!$this->filesystem->exists(dirname($path))) {
         $this->filesystem->mkdir(dirname($path));
     }
     $imagineOptions = $options->getImagineOptions();
     $imagineImage = $image->getImagine()->open($image->getPath())->resize($coordinates->getSize())->crop($coordinates->getCropStart(), $coordinates->getCropSize());
     if (isset($imagineOptions['interlace'])) {
         try {
             $imagineImage->interlace($imagineOptions['interlace']);
         } catch (ImagineRuntimeException $e) {
             // Ignore failed interlacing
         }
     }
     $imagineImage->save($path, $imagineOptions);
     return $this->createImage($image, $path);
 }