In order to work with transparent images, you have to define image as transparent. Do that immediately after creating an instance, by setting the object's default background color with setBackgroundColor method.
Source code viewer
$image = new Imagick(); $image->setBackgroundColor(new ImagickPixel('transparent')); $image->readImage($path);Programming Language: PHP