-
Notifications
You must be signed in to change notification settings - Fork 0
/
image.php
44 lines (39 loc) · 1.25 KB
/
image.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<?php
Session_Start();
$ses_id = session_id();
$fontPath = 'FreeSans.ttf'; //font type
$imgPath = 'hangouts.png'; //base image
if (isset($_POST['name']))
$string1POST = $_POST['name'];
else
$string1POST = '';
if (isset($_POST['sub']))
$string2POST = $_POST['sub'];
else
$string2POST = '';
header('Content-Description: File Transfer');
header("Content-type: application/octet-stream ");
$fontpath = realpath('.'); //replace . with a different directory if needed
putenv('GDFONTPATH='.$fontpath);
$stringAngle= 0;
$image = imagecreatefrompng($imgPath);
$color = imagecolorallocate($image, 255, 255, 255);
$string = $string1POST;
$fontSize = 25; //Top
$x = 16; //Top
$y = 310; //Top
$string2 = $string2POST;
$fontSize2 = 13; //bottom
$x2 = 16; //bottom
$y2 = 336; //bottom
$saveFile = '/tmp/' . $ses_id . '.png';
imagealphablending( $image, false );
imagesavealpha( $image, true );
imagealphablending($image, true);
imagettftext($image, $fontSize, $stringAngle, $x, $y, $color, $fontPath, $string);
imagettftext($image, $fontSize2, $stringAngle, $x2, $y2, $color, $fontPath, $string2);
imagepng($image, $saveFile);
header("Content-disposition: attachment; filename= HangoutThird.png");
readfile($saveFile);
unlink($saveFile);
?>