forked from TheGamesDB/TheGamesDB
-
Notifications
You must be signed in to change notification settings - Fork 0
/
translatedbanner.php
88 lines (70 loc) · 2.02 KB
/
translatedbanner.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
<?php
###############################
## Image Functions
###############################
###############################
## Settings
###############################
$src = 'banners/' . $filename;
## Who wouldn't set the text?!
if (!isset($text)) { $text = 'Good job, fool'; }
## Obvious font settings
if (!isset($fontface)) { $fontface = 'arial.ttf'; }
if (!isset($fontsize)) { $fontsize = 22; }
## Image crop size
if (!isset($height)) { $height = 140; }
if (!isset($width)) { $width = 758; }
## Text offsets
if (!isset($xpos)) { $xpos = 26; }
if (!isset($ypos)) { $ypos = 78; }
###############################
## Create the image
###############################
$image = imagecreatefromjpeg ($src);
if ($image == '') {
$image = imagecreatefrompng ($src);
}
if ($image == '') {
print "ERROR";
exit;
}
## Create the colors
switch ($color) {
case 'custom':
$imgcolor = imagecolorallocate($image, $color_r, $color_g, $color_b);
break;
case 'black':
$imgcolor = imagecolorallocate($image, 0, 0, 0);
break;
case 'light gray':
$imgcolor = imagecolorallocate($image, 192, 192, 192);
break;
case 'medium gray':
$imgcolor = imagecolorallocate($image, 128, 128, 128);
break;
case 'dark gray':
$imgcolor = imagecolorallocate($image, 64, 64, 64);
break;
default:
$imgcolor = imagecolorallocate($image, 255, 255, 255);
}
###############################
## Crop it to the right size
###############################
$crop = imagecreatetruecolor($width, $height);
imagecopy ( $crop, $image, 0, 0, 0, 0, $width, $height );
###############################
## Place the text
###############################
imagettftext($crop, $fontsize, 0, $xpos, $ypos, $imgcolor, $fontface, $text);
###############################
## Print the image
###############################
header ("content-type: image/jpeg");
imagejpeg ($crop);
###############################
## Clean up memory
###############################
imagedestroy ($image);
imagedestroy ($crop);
?>