-
Notifications
You must be signed in to change notification settings - Fork 0
/
image.php
54 lines (42 loc) · 1.06 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
45
46
47
48
49
50
51
52
53
54
<?php
class Process {
var $stdout;
var $stderr;
var $exit_code;
function Process($command=null) {
$this->_reset();
if (!is_null($command)) {
$this->execute($command);
}
}
function execute($command) {
// Reset myself
$this->_reset();
// Execute command
$resource = proc_open($command, array(array('pipe', 'r'), array('pipe', 'w'), array('pipe', 'w')), $pipes, null, $_ENV);
if (!is_resource($resource)) {
return;
}
// Collect STDOUT
while (!feof($pipes[1])) {
$this->stdout .= fgets($pipes[1]);
}
fclose($pipes[1]);
// Collect STDERR
while (!feof($pipes[2])) {
$this->stderr .= fgets($pipes[2]);
}
fclose($pipes[2]);
// Collect exit code
$this->exit_code = proc_close($resource);
}
function _reset() {
$this->stdout = '';
$this->stderr = '';
$this->exit_code = '';
}
}
$command = 'convert -fill \'#2276c0\' -font '.dirname(__FILE__).'/HelveticaLTStdCond.otf -pointsize 14 label:"'.strtoupper($_GET['text']).'" png:-';
$process = new Process($command);
header('Content-type: image/png');
print $process->stdout;