Skip to content

Commit

Permalink
Merge branch 'master' into PS-721-es
Browse files Browse the repository at this point in the history
# Conflicts:
#	databox/api/src/Controller/Admin/DashboardController.php
  • Loading branch information
4rthem committed Nov 26, 2024
2 parents 891ae57 + e153509 commit ddcbec9
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 5 deletions.
2 changes: 1 addition & 1 deletion databox/api/src/Controller/Admin/DashboardController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
Expand Down
31 changes: 29 additions & 2 deletions lib/php/rendition-factory/src/Command/CreateCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'));
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

namespace Alchemy\RenditionFactory\Transformer\Image\Imagine;

use Imagine\Image\ImageInterface;
use Imagine\Image\ImagineInterface;
use Imagine\Image\Point;
use Liip\ImagineBundle\Imagine\Filter\Loader\LoaderInterface;

class BackgroundFillFilterLoader implements LoaderInterface
{
public function __construct(protected ImagineInterface $imagine)
{
}

public function load(ImageInterface $image, array $options = [])
{
$background = $image->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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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(),
Expand Down

0 comments on commit ddcbec9

Please sign in to comment.