-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathgreetframe.php
163 lines (146 loc) · 4.45 KB
/
greetframe.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
<?php
header('Content-type: image/jpeg');
header('Content-Disposition: attachment; filename="'.uniqid('Greeting_').'.jpg"');
// Create Image From Existing File
if(isset($_GET['frame']))
{
$jpg_image = imagecreatefromjpeg('Greetings/'.$_GET['frame'].'.jpg');
list($frmwidth, $frmheight) = getimagesize('Greetings/'.$_GET['frame'].'.jpg') ;
}
else
{
$jpg_image = imagecreatefromjpeg('Greetings/frame_rakhi_01.jpg');
list($frmwidth, $frmheight) = getimagesize('Greetings/frame_rakhi_01.jpg') ;
}
//Get DP
if(isset($_GET['dp']))
{
$tempfilename = 'temp/'.uniqid('temp');
if(strpos($_GET['dp'],'pravatar')){
copy('http://'.$_GET['dp'], $tempfilename);
}else{
copy($_GET['dp'], $tempfilename);
}
list($width, $height) = getimagesize($tempfilename) ;
if($width>$height)
{
$modwidth = 280;
$modheight = $modwidth *($height/$width);
$mody=(-(($modheight-$modwidth)/2))+68;
$modx=661;
}
elseif($width==$height)
{
$modwidth = 280;
$modheight = 280;
$modx=661;
$mody=68;
}
else
{
$modheight = 280;
$modwidth = $modheight *($width/$height);
$mody=68;
$modx=(-(($modwidth-$modheight)/2))+661;
//$modx=0;
}
switch (exif_imagetype($tempfilename)) {
case IMAGETYPE_GIF:
$logo_image = imagecreatefromgif($tempfilename);
break;
case IMAGETYPE_PNG:
$logo_image = imagecreatefrompng($tempfilename);
break;
case IMAGETYPE_JPEG:
$logo_image = imagecreatefromjpeg($tempfilename);
break;
case IMAGETYPE_BMP:
$logo_image = imagecreatefrombmp($tempfilename);
break;
default:
break;
}
if(strpos($_GET['frame'],"ract_lay-1")!=null)
{
//$layid=
$lay_img = imagecreatefrompng('Layouts/sqr_lay_1.png');
imagealphablending( $lay_img, false );
imagesavealpha( $lay_img, true );
imagecopyresampled($jpg_image, $lay_img, 0, 0, 0, 0, $frmwidth,$frmheight,$frmwidth,$frmheight ) ;
}
imagecopyresampled($jpg_image, $logo_image, $modx, $mody, 0, 0, $modwidth,$modheight, $width,$height ) ;
// imagecopyresampled($jpg_image, $logo_image, 0, 0, 0, 0, 240,240, $width,$height ) ;
unlink($tempfilename);
}
else
{
}
// set dp
//$dp= imagecreatefromjpeg('dp.jpg');
//list($width, $height) = getimagesize('dp.jpg') ;
// imagecopyresampled($jpg_image, $dp, 661, 68, 0, 0, 280,280, $width,$height ) ;
// Allocate A Color For The Text
$txtcolorw = imagecolorallocate($jpg_image, 255, 255, 255);
$txtcolor = imagecolorallocate($jpg_image, 0, 10, 10);
// Set Path to Font File
$font_path = __dir__.'/font/ARIALUNI.TTF';
$font_path_e = __dir__.'/font/Lobster-Regular.ttf';
$font_path_h = __dir__.'/font/MANGAL.ttf';
// Set Text to Be Printed On Image
if(isset($_GET['text']) && isset($_GET['text2'])){
$text = substr($_GET['text'],0,56)."";
$text2 = substr($_GET['text2'],0,68)."";
}
elseif(isset($_GET['text']))
{
$text = substr($_GET['text'],0,160)."...";
$text2 = "";
}
else
{
$text = "Hello World!";
$text2 = "";
}
$lines = explode('|', wordwrap($text, 62, '|'));
$lines2 = explode('|', wordwrap($text2, 34, '|'));
// Starting Y position
$y = 390;
$y2 = 410;
// Loop through the lines and place them on the image
foreach ($lines as $line)
{
//imagettftext($image, $font_size, 0, 50, , $font_color, $font, $line);
// Print Text On Image
imagettftext($jpg_image, 20, 0, 671, $y+1, $txtcolorw, $font_path, $line);
imagettftext($jpg_image, 20, 0, 670, $y, $txtcolor, $font_path, $line);
// Increment Y so the next line is below the previous line
$y += 36;
}
// Loop through the lines and place them on the image
foreach ($lines2 as $line)
{
//imagettftext($image, $font_size, 0, 50, , $font_color, $font, $line);
// Print Text On Image
imagettftext($jpg_image, 12, 0, 686, $y2+1, $txtcolorw, $font_path, $line);
imagettftext($jpg_image, 12, 0, 685, $y2, $txtcolor, $font_path, $line);
$y2 += 18;
}
// Print Text On Image
//resige image
if(isset($_GET['width']))
{
$finalwidth=$_GET['width'];
$finalheight = $finalwidth *($frmheight/$frmwidth);
$tn = imagecreatetruecolor($finalwidth, $finalheight);
imagecopyresampled($tn, $jpg_image, 0, 0, 0, 0, $finalwidth,$finalheight, $frmwidth, $frmheight ) ;
// Send Image to Browser
imagejpeg($tn);
}
else
{
// Send Image to Browser
imagejpeg($jpg_image);
}
// Clear Memory
imagedestroy($jpg_image);
?>