Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?
- // Get request variables
- $month = $_GET['month'];
- $day = $_GET['day'];
- // Set knowns
- $image_file = "../../assets/images/event.jpg";
- $font = 'Arial Bold.ttf';
- // Set up image/color resources
- $image = imagecreatefromjpeg($image_file); // replace filename with $_GET['src']
- $white = ImageColorAllocate($image,255,255,255);
- $black = ImageColorAllocate($image,0,0,0);
- // Calculate starting x-pos from text length / bounding box
- $month_box = imagettfbbox("7","0",$font,strtoupper($month));
- $day_box = imagettfbbox("17","0",$font,$day);
- $start_1 = (40-($month_box[2]+$month_box[0]))/2 - .5;
- $start_2 = (40-($day_box[2]+$day_box[0]))/2 - .5;
- // Write text onto icon
- imagettftext($image,"7","0",$start_1,"11",$white,$font,strtoupper($month));
- imagettftext($image,"17","0",$start_2,"34",$black,$font,$day);
- // Output final image
- header("Content-Type: image/png");
- imagepng($image);
- imagedestroy($image);
- ?>
Add Comment
Please, Sign In to add comment