PHP 8.3.4 Released!

Imagick::roundCorners

(PECL imagick 2, PECL imagick 3)

Imagick::roundCornersRedondea las esquinas de una imagen

Descripción

Imagick::roundCorners(
    float $x_rounding,
    float $y_rounding,
    float $stroke_width = 10,
    float $displace = 5,
    float $size_correction = -6
): bool

Redondea las esquinas de una imagen. Los dos primeros parámetros controlan la cantidad de redondeo y los tres últimos parámetros se pueden usar para afinar el proceso de redondeo. Este método está disponible si Imagick ha sido compilado con la versión 6.2.9 o superior de ImageMagick.

Parámetros

x_rounding

redondeo x

y_rounding

redondeo y

stroke_width

ancho del contorno

displace

desplazamiento de la imagen

size_correction

corrección del tamaño

Ejemplos

Ejemplo #1 Usar Imagick::roundCorners():

Redondear las esquinas de una imagen

<?php

$imagen
= new Imagick();
$imagen->newPseudoImage(100, 100, "magick:rose");
$imagen->setImageFormat("png");

$imagen->roundCorners(5,3);
$imagen->writeImage("redondeada.png");
?>

Valores devueltos

Devuelve true en caso de éxito.

add a note

User Contributed Notes 2 notes

up
6
mmehdibalouchi at gmail dot com
6 years ago
Is this method deprecated?
what can we do instead ?
up
-2
ar2rsoft at gmail dot com
4 years ago
Alternative solution:
// example values
$width = 250;
$height = 250;
$cornerRadius = 10;

// create mask image
$mask = new Imagick();
$mask->newImage($width, $height, new ImagickPixel('transparent'), 'png');
// create the rounded rectangle
$shape = new ImagickDraw();
$shape->setFillColor(new ImagickPixel('black'));
$shape->roundRectangle(0, 0, $width, $height, $cornerRadius, $cornerRadius);
// draw the rectangle
$mask->drawImage($shape);
// apply mask
$image->compositeImage($mask, Imagick::COMPOSITE_DSTIN, 0, 0);

I found solution here:
https://github.com/Imagick/imagick/issues/213#issuecomment-385928740
To Top