Imagick: fuzzy edges on transparent PNG?
Posted: Wed Nov 10, 2010 7:32 am
I've made a script that creates thumbnails on-the-fly from uploaded images. The thumbs must have a reflection-effect so I'm using Imagick to create a PNG for this. The problem is that I want the reflection to be blurry because it just looks better. Now, I use gaussianBlurImage()-function to do this but since the new image is created on a transparent image the edges does NOT become blurry (fuzzy). I want the edges to be fuzzy as well! If I use a colored background it works, but NOT on a transparent one.
I've tried several different approaches to achieve this (manipulate the alpha-channel etc) but nothing works... Now, is there ANYONE out there who knows how to do this???
This is the code:
I've tried several different approaches to achieve this (manipulate the alpha-channel etc) but nothing works... Now, is there ANYONE out there who knows how to do this???
This is the code:
Code: Select all
// Create image from uploaded and resize it
$uploaded = new Imagick($_FILES["file"]["tmp_name"]);
$uploaded->scaleImage(260, 208, false);
// Create reflection
$reflection = $uploaded->clone();
$reflection->flipImage();
$reflection->setImageOpacity(0.5);
// Create new image
$image = new Imagick();
$image->newImage(300, 254, new ImagickPixel("none"));
$image->setImageFormat('png');
// Add together
$image->compositeImage($reflection, Imagick::COMPOSITE_DEFAULT, 20, 208);
$image->gaussianBlurImage(3,3);
$image->compositeImage($uploaded, Imagick::COMPOSITE_DEFAULT, 20, 0);
// Save new image
$data = $image->getImageBlob();
file_put_contents ($real_dir.$_FILES["file"]["name"], $data);