init
This commit is contained in:
54 files changed
+4604
No files matched your search
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
use function App\Support\base_path;
|
||||
|
||||
require dirname(__DIR__) . '/bootstrap/autoload.php';
|
||||
|
||||
/** Development-only export tool; cPanel needs only the generated assets. */
|
||||
function renderCommand(array $command): void
|
||||
{
|
||||
$process = proc_open($command, [0 => ['pipe', 'r'], 1 => ['pipe', 'w'], 2 => ['pipe', 'w']], $pipes);
|
||||
if (!is_resource($process)) {
|
||||
throw new RuntimeException('Could not start brand renderer.');
|
||||
}
|
||||
fclose($pipes[0]);
|
||||
stream_get_contents($pipes[1]);
|
||||
$error = stream_get_contents($pipes[2]);
|
||||
fclose($pipes[1]);
|
||||
fclose($pipes[2]);
|
||||
if (proc_close($process) !== 0) {
|
||||
throw new RuntimeException('Brand export failed: ' . $error);
|
||||
}
|
||||
}
|
||||
|
||||
$brand = base_path('public/assets/brand');
|
||||
$icon = file_get_contents($brand . '/icon.svg');
|
||||
copy($brand . '/icon.svg', base_path('public/favicon.svg'));
|
||||
foreach ([32, 192, 512, 1024] as $size) {
|
||||
renderCommand(['rsvg-convert', '-w', (string) $size, '-h', (string) $size, '-o', $brand . '/icon-' . $size . '.png', $brand . '/icon.svg']);
|
||||
}
|
||||
// Full-bleed background with the symbol inside the maskable safe area.
|
||||
$maskable = str_replace('<rect width="192" height="192" rx="44" fill="#163E37"/>',
|
||||
'<rect width="192" height="192" fill="#163E37"/><g transform="translate(19.2 19.2) scale(.8)">', $icon);
|
||||
$maskable = str_replace('</svg>', '</g></svg>', $maskable);
|
||||
file_put_contents($brand . '/icon-maskable.svg', $maskable);
|
||||
renderCommand(['rsvg-convert', '-w', '512', '-h', '512', '-o', $brand . '/icon-maskable-512.png', $brand . '/icon-maskable.svg']);
|
||||
renderCommand(['rsvg-convert', '-w', '180', '-h', '180', '-o', base_path('public/apple-touch-icon.png'), $brand . '/icon-maskable.svg']);
|
||||
renderCommand(['rsvg-convert', '-o', $brand . '/social.png', $brand . '/social.svg']);
|
||||
renderCommand(['magick', $brand . '/icon-512.png', '-define', 'icon:auto-resize=64,48,32,16', base_path('public/favicon.ico')]);
|
||||
echo "Exported Madar icons, favicons, Apple touch icon, maskable icon and social preview.\n";
|
||||
Reference in new issue
Block a user