['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('',
'', $icon);
$maskable = str_replace('', '', $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";