|
5 | 5 | namespace Intervention\Image\Drivers\Imagick\Modifiers;
|
6 | 6 |
|
7 | 7 | use Imagick;
|
| 8 | +use ImagickPixel; |
8 | 9 | use Intervention\Image\Interfaces\ImageInterface;
|
9 | 10 | use Intervention\Image\Interfaces\SpecializedInterface;
|
10 | 11 | use Intervention\Image\Modifiers\CropModifier as GenericCropModifier;
|
@@ -45,16 +46,21 @@ public function apply(ImageInterface $image): ImageInterface
|
45 | 46 | $canvas->setImageDispose($frame->native()->getImageDispose());
|
46 | 47 | }
|
47 | 48 |
|
48 |
| - // Make the entire rectangle at the position of the original image |
49 |
| - // transparent so that we can later place the original on top. |
50 |
| - // This preserves the transparency of the original and shows |
51 |
| - // the background color of the modifier in the other areas |
52 |
| - $clear = new Imagick(); |
53 |
| - $clear->newImage($frame->native()->getImageWidth(), $frame->native()->getImageHeight(), 'black'); |
54 |
| - $canvas->compositeImage($clear, Imagick::COMPOSITE_DSTOUT, ...$position); |
| 49 | + // make the rectangular position of the original image transparent |
| 50 | + // so that we can later place the original on top. this preserves |
| 51 | + // the transparency of the original and shows the background color |
| 52 | + // of the modifier in the other areas. if the original image has no |
| 53 | + // transparent area the rectangular transparency will be covered by |
| 54 | + // the original. |
| 55 | + $clearer = new Imagick(); |
| 56 | + $clearer->newImage( |
| 57 | + $frame->native()->getImageWidth(), |
| 58 | + $frame->native()->getImageHeight(), |
| 59 | + new ImagickPixel('black'), |
| 60 | + ); |
| 61 | + $canvas->compositeImage($clearer, Imagick::COMPOSITE_DSTOUT, ...$position); |
55 | 62 |
|
56 |
| - // place original frame content onto the empty colored frame canvas |
57 |
| - // with the transparent rectangle |
| 63 | + // place original frame content onto prepared frame canvas |
58 | 64 | $canvas->compositeImage($frame->native(), Imagick::COMPOSITE_DEFAULT, ...$position);
|
59 | 65 |
|
60 | 66 | // add newly built frame to container imagick
|
|
0 commit comments