/
image_convert.php
102 lines (56 loc) · 2.29 KB
/
image_convert.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
<?PHP
class image_convert{
function image_convert(){
}
function process_image($arguments, $movie, $ted_engine){
print_r($arguments);
$array = getimagesize("../../../" . substr($arguments[1],16));
$image_scaled = imagecreatetruecolor($arguments[4],$arguments[5]);
switch(substr($arguments[1],-3)){
case "jpg" : $image_to_scale = imagecreatefromjpeg("../../../" . substr($arguments[1],16));
$type = "jpg";
break;
case "gif" : $image_to_scale = imagecreatefromgif("../../../" . substr($arguments[1],16));
$type = "gif";
break;
default : break;
}
if($array[0]!=$arguments[4]||$array[1]!=$arguments[5]){
imagecopyresampled($image_scaled, $image_to_scale, 0, 0, 0, 0, $arguments[4], $arguments[5], $array[0], $array[1]);
$file_name = "../../image_process/" . "temp" . rand() . ".gif";
imagegif($image_scaled, $file_name);
chmod($file_name, 0777);
$image = $ted_engine->insert_picture($movie, $file_name,$arguments[2],$arguments[3]);
}else{
$file_name = "../../image_process/" . "temp" . rand() . ".gif";
imagegif($image_to_scale, $file_name);
chmod($file_name, 0777);
$image = $ted_engine->insert_picture($movie,$file_name,$arguments[2],$arguments[3]);
}
return $image;
}
function process_scroll_image($arguments){
$array = getimagesize("../../../" . substr($arguments[1],16));
$image_scaled = imagecreatetruecolor($arguments[4],$arguments[5]);
switch(substr($arguments[1],-3)){
case "jpg" : $image_to_scale = imagecreatefromjpeg("../../../" . substr($arguments[1],16));
$type = "jpg";
break;
case "gif" : $image_to_scale = imagecreatefromgif("../../../" . substr($arguments[1],16));
$type = "gif";
break;
default : break;
}
if($array[0]!=$arguments[4]||$array[1]!=$arguments[5]){
imagecopyresampled($image_scaled, $image_to_scale, 0, 0, 0, 0, $arguments[4], $arguments[5], $array[0], $array[1]);
$file_name = "../../../" . "temp" . rand() . ".gif";
imagegif($image_scaled, $file_name);
}else{
$file_name = "../../../" . "temp" . rand() . ".gif";
imagegif($image_to_scale, $file_name);
}
echo "RETURNED FILE NAME IS - " . $file_name . "\n";
return $file_name;
}
}
?>