Guest User

Untitled

a guest
Aug 18th, 2018
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.60 KB | None | 0 0
  1. <?php
  2.  
  3. if(isset($_POST['execute'])) {
  4.  
  5. echo "<label>Result :</label>";
  6.  
  7. $folder = "files/quote/";
  8. $overlay = $folder."overlay.png";
  9. $font_quote = "files/_font/"."Ubuntu-Medium.ttf";
  10. $font_copyright = "files/_font/"."Ubuntu-Medium.ttf";
  11. $filename = $folder.md5(rand(000,999)).".png";
  12. $quote = @$_POST['quote'] ? $_POST['quote'] : 'YOUR QUOTE';
  13. $copyright = @$_POST['copyright'] ? $_POST['copyright'] : 'Username';
  14. $backgrond = @$_POST['background'];
  15.  
  16. if (!filter_var($backgrond, FILTER_VALIDATE_URL) === false) {
  17. $bg = $backgrond;
  18. }else {
  19. $bg = get_redirect_target('https://source.unsplash.com/640x640/?'.urlencode($backgrond));
  20. }
  21.  
  22. $image = new PHPImage();
  23. $image->setQuality(10);
  24. $image->setDimensionsFromImage($overlay);
  25. $image->draw($bg);
  26. $image->draw($overlay, '50%', '75%');
  27. $image->setFont($font_quote);
  28. $image->setTextColor(array(255, 255, 255));
  29. $image->setAlignVertical('center');
  30. $image->setAlignHorizontal('center');
  31. $image->textBox($quote, array(
  32. 'fontSize' => 28,
  33. 'x' => 130,
  34. 'y' => 240,
  35. 'width' => 380,
  36. 'height' => 200,
  37. 'debug' => false
  38. ));
  39.  
  40. $image->setFont($font_copyright);
  41. $image->setTextColor(array(230, 209, 65));
  42. $image->text('CopyRight © '.$copyright, array(
  43. 'fontSize' => 15,
  44. 'x' => 0,
  45. 'y' => 535,
  46. 'width' => 640,
  47. 'height' => 20,
  48. 'debug' => false
  49. ));
  50. $image->save($filename);
  51.  
  52.  
  53. $imagebase64 = "data:image/png;base64,".base64_encode(file_get_contents($filename));
  54. echo "<a href='".$imagebase64."' target='_blank' download='$filename'><img src='".$imagebase64."'/></a>";
  55. unlink($filename);
  56. }
  57.  
  58. ?>
Advertisement
Add Comment
Please, Sign In to add comment