-
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.
* paste layers one by one, centered BC-Break - options `size` and `position` are removed - option `transparency` is renamed `opacity` to conform to values 0=transparent ; 100=full opaque color * fix : bad positioning of multiple-layers tiff add : cli `alchemy:rendition-factory:create` now accepts a directory as input (all files treated) * rename BackgroundFilter to BackgroundFillFilter (filter name = `background_fill`)
- Loading branch information
Showing
3 changed files
with
62 additions
and
4 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
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