Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

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: http://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