depage-graphics
Loading...
Searching...
No Matches
Optipng.php
Go to the documentation of this file.
1
<?php
2
3
namespace
Depage\Graphics\Optimizers;
4
5
class
Optipng
extends
Optimizer
6
{
7
protected
$version
;
8
9
public
function
__construct
(
$options
= array())
10
{
11
parent::__construct(
$options
);
12
13
if
(isset($this->options[
'optipng'
])) {
14
$this->executable = $this->options[
'optipng'
];
15
}
16
17
if
(is_null($this->executable)) {
18
$this->executable =
\Depage\Graphics\Graphics::which
(
"optipng"
);
19
}
20
21
if
($this->executable) {
22
exec($this->executable .
' --version 2>&1'
, $commandOutput, $returnStatus);
23
24
preg_match(
"/(\d+).(\d+).(\d+)/"
, $commandOutput[0], $matches);
25
26
$this->version = $matches[0];
27
}
28
}
29
30
public
function
optimize
($filename)
31
{
32
if
(!$this->executable) {
33
return
false
;
34
}
35
36
$this->command =
"{$this->executable} "
;
37
38
// 2 is the default (8 trials) -> may change between versions
39
//$this->command .= "-o 2 ";
40
41
if
(version_compare($this->version,
'0.7.0'
,
'>='
)) {
42
// strip got added in version 0.7
43
$this->command .=
"-strip all "
;
44
}
45
46
$this->command .=
"-preserve "
;
47
48
$this->command .=
" "
. escapeshellarg($filename);
49
50
return
$this->
execCommand
();
51
}
52
}
53
54
/* vim:set ft=php sw=4 sts=4 fdm=marker et : */
Depage\Graphics\Graphics\which
static which($binary)
Executes "which" command.
Definition
Graphics.php:463
Depage\Graphics\Optimizers\Optimizer
Definition
Optimizer.php:6
Depage\Graphics\Optimizers\Optimizer\$options
$options
Definition
Optimizer.php:9
Depage\Graphics\Optimizers\Optimizer\execCommand
execCommand()
Definition
Optimizer.php:16
Depage\Graphics\Optimizers\Optipng
Definition
Optipng.php:6
Depage\Graphics\Optimizers\Optipng\$version
$version
Definition
Optipng.php:7
Depage\Graphics\Optimizers\Optipng\__construct
__construct($options=array())
Definition
Optipng.php:9
Depage\Graphics\Optimizers\Optipng\optimize
optimize($filename)
Definition
Optipng.php:30
Optimizers
Optipng.php
Generated on
for depage-graphics by
doxygen
1.14.0
For an overview of all docs, go to
docs.depage.net