Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /* Passport Generator */
- /* Author: Usama Muneeb */
- // |-------frame-------------------|
- // | ^ |
- // | dst_y |
- // | V |
- // |< dst_x >|----window----| |
- // | | | |
- // | | overlay | |
- // | | | |
- // | |--------------| |
- // | |
- // | (and some text) |
- // | |
- // |-------------------------------|
- $infix_w = 64; //width of overlay.png
- $infix_h = 64; //height of overlay.png
- $placeholder_w = 64; //width of window (same as $infix_w if the window is carefully cut according to overlay size)!
- $placeholder_h = 64; //height of window (same as $infix_h if the window is carefully cut according to overlay size)!
- $dst_x = 64; // Left margin (offset) of picture placement point
- $dst_y = 64; // Top margin (offset) of picture placement point
- $frame_w = 192; //width of frame.png
- $frame_h = 192; //height of frame.png
- // create the canvas
- $dst_image = imagecreatetruecolor($frame_w,$frame_h);
- // fetch the embedded picture
- $src_image = imagecreatefrompng("overlay.png");
- // copy selected part of the picture onto the canvas
- imagecopyresampled($dst_image, $src_image, $dst_x, $dst_y, 0, 0, $frame_w, $frame_h,
- ($infix_w/$placeholder_w)*$frame_w, ($infix_h/$placeholder_h)*$frame_h);
- //fetch the frame with transparent window
- //as of yet, frame.png MUST have the picture placeholder area set transparent
- // using Photoshop or equivalent.
- $src = imagecreatefrompng("frame.png");
- // place the frame over the canvas
- imagecopy($dst_image, $src, 0, 0, 0, 0, $frame_w, $frame_h);
- // allocate color and font
- $black = imagecolorallocate($dst_image, 255, 255, 255);
- $font_path = "./myFont.ttf";
- // write text
- imagettftext($dst_image, 20, 0, 30, 30, $black, $font_path, "Lorem Ipsum");
- // send image to browser
- header('Content-Type: image/png');
- imagepng($dst_image);
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement