Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- //Create a ImagickDraw object to draw into.
- $draw = new ImagickDraw();
- //Create an ImagickPixel with the predefined color 'red'
- $color = new \ImagickPixel('red');
- //Set the stroke and fill colour and draw a rectangle
- $draw->setStrokeColor($color);
- $draw->setFillColor($color);
- $draw->rectangle(200, 200, 300, 300);
- //Create an image object so that the draw commands can
- //be rendered
- $image = new Imagick();
- $image->newImage(500, 500, "yellow");
- $image->setImageFormat("png");
- //Render the draw commands in the ImagickDraw object
- //into the image.
- $image->drawImage($draw);
- //Send the image to the browser
- header("Content-Type: image/png");
- echo $image->getImageBlob();
- //This produces an image of a red rectangle on a yellow background
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement