function setImageChannelMask($image_path, $channel, $rotation_angle, $rotation_channel) { $imagick = new \Imagick(realpath($image_path)); $imagick->setImageChannelMask($channel); if ($rotation_channel === 0) { $imagick->rotationalBlurImage($rotation_angle); } else { $imagick->rotationalBlurImage($rotation_angle, $rotation_channel); } header("Content-Type: image/jpeg"); echo $imagick->getImageBlob(); }