public function clipImage($sourceImage, $maskImage, $format)
    {
        $source = new \Imagick();
        $source->readImageBlob($sourceImage);

        $mask = new \Imagick();
        $mask->setBackgroundColor(new \ImagickPixel('transparent'));

        $mask->readImageBlob($maskImage);
        $mask->setImageFormat($format);

        $source->setImageMatte(1);
        $source->compositeImage($mask, \Imagick::COMPOSITE_DSTIN, 0, 0);
        $mask->destroy();
        unset($mask);
        $this->colorNumber = $source->getImageColors();
        $content = $source->getimageblob();
//        $mask->compositeImage($source, \Imagick::COMPOSITE_DSTOUT, 0, 0);
//        $content = $mask->getimageblob();
        $source->destroy();
        unset($source);
        return $content;
    }