forked from rpitv/rpits
-
Notifications
You must be signed in to change notification settings - Fork 1
/
im_render_title.php
83 lines (64 loc) · 1.96 KB
/
im_render_title.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
<?php
include("include.php");
include("imagick_include.php");
$id = $_GET["id"];
$result = dbquery("SELECT * from titles where id=\"$id\" LIMIT 1;");
$titleRow = mysql_fetch_array($result);
$template_id = $titleRow["template"];
$result = dbquery("SELECT * from templates where id=\"$template_id\" LIMIT 1;");
$templateRow = mysql_fetch_array($result);
$templateXML = fopen($templateRow["path"],"r");
$contents = stream_get_contents($templateXML);
$canvas = new Imagick();
$canvas->newImage(1920,1080,"none","png");
$xml = new SimpleXMLElement($contents);
if($xml->geo->blackBox)
{
foreach($xml->geo->blackBox as $box)
{
$l = dbFetch($id,$box);
blackBox($canvas,$l["x"],$l["y"],$l["w"],$l["h"]);
}
}
if($xml->geo->slantRectangle)
{
foreach($xml->geo->slantRectangle as $slantRectangle)
{
$sR = dbFetch($id,$slantRectangle);
slantRectangle($canvas,$sR["x"],$sR["y"],$sR["w"],$sR["h"],$sR["color"]);
}
}
if($xml->overlay->shadowText)
{
foreach($xml->overlay->shadowText as $text)
{
$t = dbFetch($id,$text);
shadowedText($canvas,$t["x"],$t["y"],$t["w"],$t["h"],$t["text"],$t["gravity"],$t["font"],$t["color"]);
}
}
if($xml->overlay->plainText)
{
foreach($xml->overlay->plainText as $text)
{
$t = dbFetch($id,$text);
plainText($canvas,$t["x"],$t["y"],$t["w"],$t["h"],$t["text"],$t["gravity"],$t["font"],$t["color"], true);
}
}
if($xml->overlay->placeImage)
{
foreach($xml->overlay->placeImage as $image)
{
$l = dbFetch($id,$image);
//print_r($l);
placeImage($canvas,$l["x"],$l["y"],$l["w"],$l["h"],$l["path"]);
}
}
header("Content-Type: image/png");
echo $canvas;
$thumb = $canvas->clone();
$thumb->cropImage(1440,1080,0,0);
$thumb->resizeImage(53,40,Imagick::FILTER_TRIANGLE,1);
$thumb->writeImage('thumbs/' . $titleRow["filename"] . '.png');
$canvas->setImageDepth(8);
$canvas->writeImage('out/' . $titleRow["filename"] . '.png');
?>