@@ -224,8 +224,11 @@ public function rgb(bool $force = false): static
224
224
225
225
// If it's a Vips image, we can extract the RGB channels
226
226
if ($ this ->image instanceof \Imagine \Vips \Image) {
227
- $ vipImage = $ this ->image ->copy ()->getVips ()->extract_band (0 , ['n ' => 3 ]);
228
- return new self ($ vipImage , 3 );
227
+ /** @var \Imagine\Vips\Image $image */
228
+ $ image = $ this ->image ->copy ();
229
+ $ vipImage = $ image ->getVips ()->extract_band (0 , ['n ' => 3 ]);
230
+ $ image ->setVips ($ vipImage );
231
+ return new self ($ image , 3 );
229
232
}
230
233
231
234
return new self ($ this ->image ->copy (), 3 );
@@ -400,16 +403,21 @@ public function applyMask(Image $mask): static
400
403
$ this ->image instanceof \Imagine \Vips \Image => $ this ->image ->copy ()->applyMask ($ mask ->image ),
401
404
402
405
$ this ->image instanceof \Imagine \Imagick \Image => (function () use ($ mask ) {
403
- $ maskImagick = $ mask ->image ->copy ()->mask ()->getImagick ();
404
- $ imageImagick = clone $ this ->image ->getImagick ();
405
-
406
- $ maskImagick ->compositeImage ($ imageImagick , Imagick::COMPOSITE_DSTIN , 0 , 0 );
407
- $ imageImagick ->compositeImage ($ maskImagick , Imagick::COMPOSITE_COPYOPACITY , 0 , 0 );
408
-
409
- $ maskImagick ->clear ();
410
- $ maskImagick ->destroy ();
411
-
412
- return new \Imagine \Imagick \Image ($ imageImagick , $ this ->image ->palette (), $ this ->image ->metadata ());
406
+ // $maskImagick = $mask->image->copy()->mask()->getImagick();
407
+ // $imageImagick = clone $this->image->getImagick();
408
+ //
409
+ // $maskImagick->compositeImage($imageImagick, Imagick::COMPOSITE_DSTIN, 0, 0);
410
+ // $imageImagick->compositeImage($maskImagick, Imagick::COMPOSITE_COPYOPACITY, 0, 0);
411
+ //
412
+ // $maskImagick->clear();
413
+ // $maskImagick->destroy();
414
+ //
415
+ // return new \Imagine\Imagick\Image($imageImagick, $this->image->palette(), $this->image->metadata());
416
+ $ image = $ this ->image ->copy ();
417
+ $ maskImage = $ mask ->image ->copy ();
418
+ $ maskImage ->effects ()->negative ();
419
+ $ image ->applyMask ($ maskImage );
420
+ return $ image ;
413
421
})(),
414
422
415
423
$ this ->image instanceof \Imagine \Gd \Image => (function () use ($ mask ) {
0 commit comments