Balázs Édes
Balázs Édes

Reputation: 13807

Imagick motion blur on composite, transparent image

I'm trying to compose an image of multiple existing images, and apply motion blur on it. I'm using a transparent canvas, to draw all the images. Here is the result:enter image description here

As you can see, the blurred parts won't leave the non-transparent parts of the individual images. How could i make them blur outside those parts?

Update: This is what i meant by blurring the edges too:

enter image description here

Here is my code:

header("Content-Type: image/png");

$images = array("a.png","b.png","c.png");

$canvas = new Imagick();
$canvas->newImage(128*3, 128, new ImagickPixel("rgba(0,0,0,0)"));
$canvas->setImageFormat("png");

for($i=0; $i<count($images); $i++)
{
    $img = new Imagick($images[$i]);
    $canvas->compositeimage($img, Imagick::COMPOSITE_DEFAULT, $i*128, 0);
}
$canvas->motionblurimage(100, 40, 90);

echo $canvas;

Thanks for any help or directions how to fix this!

Upvotes: 2

Views: 896

Answers (1)

frostyterrier
frostyterrier

Reputation: 1912

Try adding the parameter for the channel:

$canvas->motionblurimage(100, 40, 90, Imagick::CHANNEL_ALL);

I think that the default channel setting makes the effect confined to the non-transparent parts.

When I use that exact line, the image gets really blurred - probably more blurred than you want. The first two values might need to be reduced, maybe even halved.

Upvotes: 3

Related Questions