Skip to content

Commit b62b125

Browse files
fix: workaround for transparent background in PNG mode (DenverCoder1#453)
Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
1 parent fc1ce8e commit b62b125

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/card.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -494,6 +494,15 @@ function convertSvgToPng(string $svg): string
494494
$svg = preg_replace("/(animation: currstreak[^;'\"]+)/m", "font-size: 28px;", $svg);
495495
$svg = preg_replace("/<a \X*?>(\X*?)<\/a>/m", '\1', $svg);
496496

497+
// replace all fully transparent colors in fill or stroke with "none"
498+
// this is a workaround for what seems to be a bug in inkscape where rgba alpha values are ignored
499+
// TODO: find a way to make partially transparent colors work (eg. #ffffff50)
500+
$svg = preg_replace(
501+
"/(fill|stroke)=['\"](?:#[0-9a-fA-F]{6}00|#[0-9a-fA-F]{3}0|transparent)['\"]/m",
502+
'\1="none"',
503+
$svg
504+
);
505+
497506
// escape svg for shell
498507
$svg = escapeshellarg($svg);
499508

0 commit comments

Comments
 (0)