Guest User

Untitled

a guest
Feb 4th, 2019
85
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.  
  3. error_reporting(E_ALL);
  4. ini_set( 'display_errors','1');
  5.  
  6. /* Create a new imagick object */
  7. $im = new Imagick();
  8.  
  9. /* Create new image. This will be used as fill pattern */
  10. $im->newPseudoImage(50, 50, "gradient:red-black");
  11.  
  12. /* Create imagickdraw object */
  13. $draw = new ImagickDraw();
  14.  
  15. /* Start a new pattern called "gradient" */
  16. $draw->pushPattern('gradient', 0, 0, 50, 50);
  17.  
  18. /* Composite the gradient on the pattern */
  19. $draw->composite(Imagick::COMPOSITE_OVER, 0, 0, 50, 50, $im);
  20.  
  21. /* Close the pattern */
  22. $draw->popPattern();
  23.  
  24. /* Use the pattern called "gradient" as the fill */
  25. $draw->setFillPatternURL('#gradient');
  26.  
  27. /* Set font size to 52 */
  28. $draw->setFontSize(52);
  29.  
  30. /* Annotate some text */
  31. $draw->annotation(20, 50, "Hello World!");
  32.  
  33. /* Create a new canvas object and a white image */
  34. $canvas = new Imagick();
  35. $canvas->newImage(350, 70, "white");
  36.  
  37. /* Draw the ImagickDraw on to the canvas */
  38. $canvas->drawImage($draw);
  39.  
  40. /* 1px black border around the image */
  41. $canvas->borderImage('black', 1, 1);
  42.  
  43. /* Set the format to PNG */
  44. $canvas->setImageFormat('png');
  45.  
  46. /* Output the image */
  47. header("Content-Type: image/png");
  48. echo $canvas;
  49. ?>
RAW Paste Data