Guest User

Untitled

a guest
Jun 19th, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 KB | None | 0 0
  1. <?
  2.  
  3. // Get request variables
  4. $month = $_GET['month'];
  5. $day = $_GET['day'];
  6.  
  7. // Set knowns
  8. $image_file = "../../assets/images/event.jpg";
  9. $font = 'Arial Bold.ttf';
  10.  
  11. // Set up image/color resources
  12. $image = imagecreatefromjpeg($image_file); // replace filename with $_GET['src']
  13. $white = ImageColorAllocate($image,255,255,255);
  14. $black = ImageColorAllocate($image,0,0,0);
  15.  
  16. // Calculate starting x-pos from text length / bounding box
  17. $month_box = imagettfbbox("7","0",$font,strtoupper($month));
  18. $day_box = imagettfbbox("17","0",$font,$day);
  19. $start_1 = (40-($month_box[2]+$month_box[0]))/2 - .5;
  20. $start_2 = (40-($day_box[2]+$day_box[0]))/2 - .5;
  21.  
  22. // Write text onto icon
  23. imagettftext($image,"7","0",$start_1,"11",$white,$font,strtoupper($month));
  24. imagettftext($image,"17","0",$start_2,"34",$black,$font,$day);
  25.  
  26. // Output final image
  27. header("Content-Type: image/png");
  28. imagepng($image);
  29.  
  30. imagedestroy($image);
  31.  
  32. ?>
Add Comment
Please, Sign In to add comment