$watermark = new \Imagick(); $watermark->readImage($avatarpath); $watermark->scaleImage(160, 160, true); $watermark->setFormat('png'); $mask = new \Imagick(); $mask->newImage($watermark->getImageWidth(), $watermark->getImageHeight(), 'none'); $draw = new \ImagickDraw(); $draw->setFillColor('white'); $draw->roundRectangle(0, 0, $watermark->getImageWidth() - 1, $watermark->getImageHeight() - 1, $watermark->getImageWidth() / 2, $watermark->getImageHeight() / 2); $mask->drawImage($draw); $watermark->setImageMatte(1); // Apply the mask to the original image $watermark->compositeImage($mask, \imagick::COMPOSITE_DSTIN, 0, 0);
标签:draw,watermark,mask,圆角,imagick,new,php,getImageWidth From: https://www.cnblogs.com/newmiracle/p/17395841.html