diff --git a/databox/api/src/Controller/Admin/DashboardController.php b/databox/api/src/Controller/Admin/DashboardController.php index e4530ade3..4c4ff2397 100644 --- a/databox/api/src/Controller/Admin/DashboardController.php +++ b/databox/api/src/Controller/Admin/DashboardController.php @@ -102,7 +102,7 @@ public function configureMenuItems(): iterable $submenu4 = [ MenuItem::linkToCrud('Integration', 'fa fa-gear', WorkspaceIntegration::class), MenuItem::linkToCrud('Integration Data', 'fa fa-database', IntegrationData::class), - MenuItem::linkToCrud('Integration Tokens', 'fa fa-fingerprint', IntegrationToken::class), + MenuItem::linkToCrud('Integration Token', 'fa fa-fingerprint', IntegrationToken::class), MenuItem::linkToCrud('Env', 'fa fa-database', WorkspaceEnv::class), MenuItem::linkToCrud('Secret', 'fa fa-lock', WorkspaceSecret::class), MenuItem::linkToRoute('Help', 'fa fa-question', 'admin_integrations_help'), diff --git a/lib/php/rendition-factory/src/Command/CreateCommand.php b/lib/php/rendition-factory/src/Command/CreateCommand.php index 3fc870e70..2317a9ff1 100644 --- a/lib/php/rendition-factory/src/Command/CreateCommand.php +++ b/lib/php/rendition-factory/src/Command/CreateCommand.php @@ -45,15 +45,42 @@ protected function configure(): void protected function execute(InputInterface $input, OutputInterface $output): int { - $time = microtime(true); - $mimeType = $input->getOption('type'); + $ret = 0; $src = $input->getArgument('src'); + if (is_dir($src)) { + if (false === ($od = opendir($src))) { + $output->writeln(sprintf('Directory "%s" could not be opened.', $src)); + + return 1; + } + while ($f = readdir($od)) { + if ('.' === $f || '..' === $f) { + continue; + } + $ret |= $this->doFile($input, $output, $src.'/'.$f); + } + closedir($od); + } else { + $ret = $this->doFile($input, $output, $src); + } + + return $ret; + } + + protected function doFile(InputInterface $input, OutputInterface $output, string $src): int + { if (!file_exists($src)) { $output->writeln(sprintf('File "%s" does not exist.', $src)); return 1; } + $time = microtime(true); + $output->writeln(''); + $output->writeln(sprintf('Processing file: %s', $src)); + + $mimeType = $input->getOption('type'); + if (null === $mimeType) { $mimeType = $this->mimeTypeGuesser->guessMimeTypeFromPath($src); $output->writeln(sprintf('MIME type guessed: %s', $mimeType ?? 'unknown')); diff --git a/lib/php/rendition-factory/src/Transformer/Image/Imagine/BackgroundFillFilterLoader.php b/lib/php/rendition-factory/src/Transformer/Image/Imagine/BackgroundFillFilterLoader.php new file mode 100644 index 000000000..17c8a6533 --- /dev/null +++ b/lib/php/rendition-factory/src/Transformer/Image/Imagine/BackgroundFillFilterLoader.php @@ -0,0 +1,32 @@ +palette()->color( + $options['color'] ?? '#fff', + $options['opacity'] ?? 100, + ); + $canvas = $this->imagine->create($image->getSize(), $background); + + // This is a workaround to avoid a bug in Imagine that causes wrong positionning + // when the image has multiple layers + $unused = $image->layers()[0]; + + $canvas->paste($image, new Point(0, 0)); + + return $canvas; + } +} diff --git a/lib/php/rendition-factory/src/Transformer/Image/Imagine/ImagineFilterFactory.php b/lib/php/rendition-factory/src/Transformer/Image/Imagine/ImagineFilterFactory.php index 3cd7eba74..71985bbae 100644 --- a/lib/php/rendition-factory/src/Transformer/Image/Imagine/ImagineFilterFactory.php +++ b/lib/php/rendition-factory/src/Transformer/Image/Imagine/ImagineFilterFactory.php @@ -10,7 +10,6 @@ use Liip\ImagineBundle\Imagine\Filter\FilterConfiguration; use Liip\ImagineBundle\Imagine\Filter\FilterManager; use Liip\ImagineBundle\Imagine\Filter\Loader\AutoRotateFilterLoader; -use Liip\ImagineBundle\Imagine\Filter\Loader\BackgroundFilterLoader; use Liip\ImagineBundle\Imagine\Filter\Loader\CropFilterLoader; use Liip\ImagineBundle\Imagine\Filter\Loader\DownscaleFilterLoader; use Liip\ImagineBundle\Imagine\Filter\Loader\FixedFilterLoader; @@ -63,7 +62,7 @@ public function createFilterLoaders(TransformationContextInterface $context): ar $context, $this->imagine, ), - 'background' => new BackgroundFilterLoader($this->imagine), + 'background_fill' => new BackgroundFillFilterLoader($this->imagine), 'strip' => new StripFilterLoader(), 'scale' => new ScaleFilterLoader(), 'upscale' => new UpscaleFilterLoader(),