-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into PS-721-es
# Conflicts: # databox/api/src/Controller/Admin/DashboardController.php
- Loading branch information
Showing
4 changed files
with
63 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
lib/php/rendition-factory/src/Transformer/Image/Imagine/BackgroundFillFilterLoader.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters