Advertisement
Feldon

Imagick Example

May 3rd, 2017
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.25 KB | None | 0 0
  1. <?php
  2. // Load our signature base or background image.
  3. $sig = new Imagick('images/sig/sigbackground.png');
  4.  
  5. // Load a class icon
  6. $class_icon = new Imagick(strtolower($soe_character_data->class).'.png');
  7.  
  8. // Composite the class icon onto the background image.
  9. $sig->compositeImage($class_icon, $class_icon->getImageCompose(), 19, 49);
  10.  
  11. // Create our temp drawing object.
  12. $draw = new ImagickDraw();
  13.  
  14. // Pick a different font based on the character's server, in this case we load an OpenType font stored in my directory.
  15. if ($soe_character_data->server == 'Barren Sky') {
  16.     $draw->setFont('Century-Schoolbook-Bold');
  17. } else {
  18.     $draw->setFont('/home/********/public_html/images/sig/fedrascbold.otf');
  19. }
  20.  
  21. // Set font size
  22. $draw->setFontSize(20);
  23.  
  24. // Set draw color
  25. $draw->setFillColor('#fefcdc');
  26.  
  27. // Add character name
  28. $sig->annotateImage ($draw, 19, 34, 0, $soe_character_data->name_first );
  29.  
  30. // Text alignment
  31. $draw->setTextAlignment(Imagick::ALIGN_CENTER);
  32. $draw->setTextAlignment(Imagick::ALIGN_LEFT);
  33.  
  34. // Delete old file if it exists
  35. unlink($filename);
  36.  
  37. // Write out the new file
  38. $sig->setImageCompression(Imagick::COMPRESSION_JPEG);
  39. $sig->setImageCompressionQuality(92);
  40. $sig->setImageFormat( "jpeg" );
  41. $sig->writeImage($filename);
  42. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement