Advertisement
Danack

Untitled

Oct 16th, 2013
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.77 KB | None | 0 0
  1. <?php
  2.  
  3. //Create a ImagickDraw object to draw into.
  4. $draw = new ImagickDraw();
  5.  
  6. //Create an ImagickPixel with the predefined color 'red'
  7. $color = new \ImagickPixel('red');
  8.  
  9. //Set the stroke and fill colour and draw a rectangle
  10. $draw->setStrokeColor($color);
  11. $draw->setFillColor($color);
  12. $draw->rectangle(200, 200, 300, 300);
  13.  
  14. //Create an image object so that the draw commands can
  15. //be rendered
  16. $image = new Imagick();
  17. $image->newImage(500, 500, "yellow");
  18. $image->setImageFormat("png");
  19.  
  20. //Render the draw commands in the ImagickDraw object
  21. //into the image.
  22. $image->drawImage($draw);
  23.  
  24. //Send the image to the browser
  25. header("Content-Type: image/png");
  26. echo $image->getImageBlob();
  27.  
  28.  
  29.  
  30. //This produces an image of a red rectangle on a yellow background
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement