We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Rounded corners with Imagcik

Is it possible to make rounded corners with Imagick Adapter? I don't see such method in documentation, but Imagick has this method: https://php.net/manual/en/imagick.roundcorners.php



362
Accepted
answer
edited Nov '15

You could extend the existing Imagick adapter, and add a 'roundCorners' method.

class ImagickExtended extends \Phalcon\Image\Adapter\Imagick
{
    public function roundCorners($xRounding, $yRounding, $stokeWidth = 10, $displace = 5, $sizeCorrection = -6)
    {
        return $this->getInternalImInstance()->roundCorners($xRounding, $yRounding, $stokeWidth, $displace, $sizeCorrection);
    }
}

Or, considering the provided Imagick adapter provides a 'getInternalImInstance' method that is publicly accessible, you could just look at getting the instance and calling 'roundCorners' where you need to.

class MyController extends Controller
{
    public function roundAction()
    {
        $image = new Phalcon\Image\Adapter\Imagick("upload/test.jpg");
        $image->getInternalImInstance()->roundCorners(24, 24);
        if ($image->save()) {
            // ...code...
        }
    }
}

Take a look at the code structure for the Imagick class provided in Phalcon here: https://github.com/phalcon/phalcon-devtools/blob/master/ide/2.0.8/Phalcon/image/adapter/Imagick.php