-
Notifications
You must be signed in to change notification settings - Fork 1
/
smusher.php
71 lines (55 loc) · 1.45 KB
/
smusher.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
<?php
function help() {
echo "Optimize a single image or a whole folder in the cloud.\n";
echo "\n";
echo "gif's:\n";
echo " - called with a folder gif`s will not be optimized\n";
echo " - called on a singe .gif, it will be optimized if it is optimizeable\n";
echo "\n";
echo "Usage:\n";
echo " php smusher.php /images [options]\n";
echo " php smusher.php /images/x.png [options]\n";
echo "\n";
echo "Options are:\n";
echo str_pad(" -q, --quiet", 26, " ") . "no output\n";
echo str_pad(" -c, --convert-gifs", 26, " ") . "convert all .gif's in the given folder\n";
echo str_pad(" -pc, --pretend", 26, " ") . "no changes are made\n";
echo str_pad(" -r, --recursive", 26, " ") . "execute the action on all subdirectories\n";
echo str_pad(" -h, --help", 26, " ") . "show this\n";
exit;
}
if ($_SERVER['argc'] == 1)
help();
require_once 'smush.php';
$options = array();
$path = false;
$arguments = array_splice($_SERVER['argv'], 1);
foreach ($arguments as $arg) {
$is_option = preg_match('/^-/', $arg);
if ($is_option && !$path)
help();
switch ($arg) {
case '--convert-gifs':
case '-c':
$options[] = 'gifs';
break;
case '--quiet':
case '-q':
$options[] = 'quiet';
break;
case '--pretend':
case '-p':
$options[] = 'pretend';
break;
case '--recursive':
case '-r':
$options[] = 'recursive';
break;
default:
if ($is_option || $path)
help();
$path = $arg;
}
}
smush::it($path, $options);
?>