2021-11-25 21:36:21 +00:00
|
|
|
<?php // This file is part of LibreQR, which is distributed under the GNU AGPLv3+ license
|
2021-03-07 22:03:33 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
A small script that can be used to generate LibreQR's icons
|
|
|
|
*/
|
|
|
|
|
2020-03-06 20:34:31 +00:00
|
|
|
if (php_sapi_name() == "cli") {
|
|
|
|
if (isset($argv[1])) {
|
|
|
|
$done = array();
|
|
|
|
$line = "";
|
|
|
|
$theme = $argv[1];
|
|
|
|
|
|
|
|
for ($pow = 0; $pow <= 3; $pow++) {
|
|
|
|
for ($mult = 1; $mult <= 4; $mult++) {
|
|
|
|
$size = $mult * 2**(4+$pow);
|
|
|
|
if (!in_array($size, $done)) {
|
|
|
|
shell_exec("convert themes/" . $theme . "/icons/source.png -scale " . $size . "x" . $size . " themes/" . $theme . "/icons/" . $size . ".png");
|
|
|
|
shell_exec("pngquant -f themes/" . $theme . "/icons/" . $size . ".png --output themes/" . $theme . "/icons/" . $size . ".png");
|
|
|
|
$done[] = $size;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
foreach ($done as $done) {
|
|
|
|
$line = $line . ", " . $done;
|
|
|
|
}
|
|
|
|
|
|
|
|
echo substr($line, 2) . "\n";
|
|
|
|
|
|
|
|
} else {
|
|
|
|
echo "Usage: php themes/resize.php <theme name>\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
2020-03-17 13:02:31 +00:00
|
|
|
echo "Available only via CLI for security reasons. Use 'php themes/resize.php <theme name>'";
|
2020-03-06 20:34:31 +00:00
|
|
|
}
|