Snippets - GD

Snippets index page

Create some text as an image - Anthony 14/6/2008

This creats a background with a border and adds text to it.

  1. <?php
  2. // Create the canvas
  3. $canvas imagecreate15080 );
  4. // First colour - this will be the default colour for the canvas
  5. $light_blue imagecolorallocate$canvas176226255 );
  6. // The second colour - to be used for the text
  7. $black imagecolorallocate$canvas00);
  8. // Path to the font you are going to use
  9. $font "verdana.ttf";
  10. // Text to write
  11. $text "Text";
  12. // Font size
  13. $size "40";
  14. // Add the text to the canvas
  15. imageTTFText$canvas$size01560$black$font$text );
  16. // Save as Text.jpg
  17. imagejpeg$canvas"Text.jpg" );
  18. // Clear the memory of the tempory image 
  19. ImageDestroy$canvas );
  20. ?>

For more examples and information check out the main Imagemagick section.

Change a png to a jpg View

Create some text as an image View

Crop an image View

Display image without saving View

Grayscale image View

Resize an image View

Rotate an image View

Watermark an image View