Advertisement
Guest User

Untitled

a guest
Sep 16th, 2019
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.15 KB | None | 0 0
  1. <?php
  2.  
  3. /* Passport Generator */
  4. /* Author: Usama Muneeb */
  5.  
  6. // |-------frame-------------------|
  7. // | ^ |
  8. // | dst_y |
  9. // | V |
  10. // |< dst_x >|----window----| |
  11. // | | | |
  12. // | | overlay | |
  13. // | | | |
  14. // | |--------------| |
  15. // | |
  16. // | (and some text) |
  17. // | |
  18. // |-------------------------------|
  19.  
  20. $infix_w = 64; //width of overlay.png
  21. $infix_h = 64; //height of overlay.png
  22.  
  23. $placeholder_w = 64; //width of window (same as $infix_w if the window is carefully cut according to overlay size)!
  24. $placeholder_h = 64; //height of window (same as $infix_h if the window is carefully cut according to overlay size)!
  25.  
  26. $dst_x = 64; // Left margin (offset) of picture placement point
  27. $dst_y = 64; // Top margin (offset) of picture placement point
  28.  
  29. $frame_w = 192; //width of frame.png
  30. $frame_h = 192; //height of frame.png
  31.  
  32. // create the canvas
  33. $dst_image = imagecreatetruecolor($frame_w,$frame_h);
  34.  
  35. // fetch the embedded picture
  36. $src_image = imagecreatefrompng("overlay.png");
  37.  
  38. // copy selected part of the picture onto the canvas
  39. imagecopyresampled($dst_image, $src_image, $dst_x, $dst_y, 0, 0, $frame_w, $frame_h,
  40. ($infix_w/$placeholder_w)*$frame_w, ($infix_h/$placeholder_h)*$frame_h);
  41.  
  42. //fetch the frame with transparent window
  43. //as of yet, frame.png MUST have the picture placeholder area set transparent
  44. // using Photoshop or equivalent.
  45. $src = imagecreatefrompng("frame.png");
  46.  
  47. // place the frame over the canvas
  48. imagecopy($dst_image, $src, 0, 0, 0, 0, $frame_w, $frame_h);
  49.  
  50. // allocate color and font
  51. $black = imagecolorallocate($dst_image, 255, 255, 255);
  52. $font_path = "./myFont.ttf";
  53.  
  54. // write text
  55. imagettftext($dst_image, 20, 0, 30, 30, $black, $font_path, "Lorem Ipsum");
  56.  
  57. // send image to browser
  58. header('Content-Type: image/png');
  59. imagepng($dst_image);
  60. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement