PHP | ImagickDraw affine() Function Last Updated : 23 Dec, 2019 Summarize Comments Improve Suggest changes Share Like Article Like Report The ImagickDraw::affine() function is an inbuilt function in PHP which is used to adjust the current affine transformation matrix. Syntax: bool ImagickDraw::affine( array $affine ) Parameters: This function accepts a single parameter $affine which holds the array containing the affine matrix parameters. Return Value: This function returns TRUE on success. Exceptions: This function throws ImagickException on error. Below given programs illustrate the ImagickDraw::affine() function in PHP: Program 1: php <?php // Create a new Imagick object $imagick = new Imagick(); // Create a image on imagick object with // green background $imagick->newImage(800, 250, 'green'); // Create a new ImagickDraw object $draw = new ImagickDraw(); // Translate the object $draw->translate(100, 100); // Apply the affine() function $draw->affine(array("sx" => 7, "sy" => 1, "rx" => 9, "ry" => 0, "tx" => 200, "ty" => 0)); // Draw a rectangle $draw->rectangle(-50, -50, 50, 50); // Render the draw commands in the ImagickDraw object $imagick->drawImage($draw); // Show the output $imagick->setImageFormat("png"); header("Content-Type: image/png"); echo $imagick->getImageBlob(); ?> Output: Program 2: php <?php //Create a new Imagick object $imagick = new Imagick(); // Create a image on imagick object with // purple background $imagick->newImage(800, 250, 'purple'); // Create a new ImagickDraw object $draw = new ImagickDraw(); // Translate the object $draw->translate(100, 100); // Apply the affine() function $draw->affine(array("sx" => 2, "sy" => 1, "rx" => 0, "ry" => 0, "tx" => 0, "ty" => 0)); // Draw a rectangle $draw->rectangle(0, -50, 50, 50); // Draw a rectangle $draw->rectangle(100, 50, 150, 100); // Draw a rectangle $draw->rectangle(200, -10, 250, 90); // Render the draw commands in the ImagickDraw object $imagick->drawImage($draw); // Show the output $imagick->setImageFormat("png"); header("Content-Type: image/png"); echo $imagick->getImageBlob(); ?> Output: Reference: https://www.php.net/manual/en/imagickdraw.affine.php Comment More infoAdvertise with us Next Article PHP | ImagickDraw bezier() Function G gurrrung Follow Improve Article Tags : Web Technologies PHP PHP-function PHP-Imagick Similar Reads PHP | ImagickDraw clone() Function The ImagickDraw::clone() function is an inbuilt function in PHP which is used to make an exact copy of the specified ImagickDraw object. Syntax: ImagickDraw ImagickDraw::clone( void ) Parameters: This function doesnât accepts any parameter. Return Value: This function returns the exact copy of the s 2 min read PHP | ImagickDraw bezier() Function The ImagickDraw::bezier() function is an inbuilt function in Imagick library of PHP which is used to draw bezier curve. Syntax: bool ImagickDraw::bezier( $coordinates ) Parameters: This function accepts a single parameter as the multidimensional array which takes the points through which curve is to 1 min read PHP | ImagickDraw circle() Function The ImagickDraw::circle() function is an inbuilt function in Imagick library of PHP which is used to draw a circle. Syntax: bool ImagickDraw::circle( $ox, $oy, $px, $py ) Parameters: This function accepts four parameters as mentioned above and described below: $ox: This parameter takes the value of 1 min read PHP | ImagickDraw ellipse() Function The ImagickDraw::ellipse() function is an inbuilt function in PHP which is used to draw an ellipse on the image. Syntax: bool ImagickDraw::ellipse( float $ox, float $oy, float $rx, float $ry, float $start, float $end ) Parameters: This function accepts six parameters as mentioned above and described 2 min read PHP | ImagickDraw annotation() Function The ImagickDraw::annotation() function is an inbuilt function in PHP which is used to draw the text on the image. Syntax: bool ImagickDraw::annotation( $x, $y, $text ) Parameters: This function accepts three parameters as mentioned above and described below: $x: This parameter is used to hold the va 3 min read PHP | ImagickDraw color() Function The ImagickDraw::color() function is an inbuilt function in PHP which is used to draw color on the image using the current fill color, starting at the specified position, and using specified paint method. Syntax: bool ImagickDraw::color( float $x, float $y, int $paintMethod ) Parameters: This functi 2 min read Like