Skip to content

Commit 30e25c2

Browse files
authored
Force Imagick to interpret the blob as an SVG (#164)
1 parent 87fa4b7 commit 30e25c2

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/card.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ function echoAsPng(string $svg): void
317317
{
318318
// trim off all whitespaces to make it a valid SVG string
319319
$svg = trim($svg);
320-
320+
321321
// remove style and animations
322322
$svg = preg_replace('/(<style>\X*<\/style>)/m', '', $svg);
323323
$svg = preg_replace('/(opacity: 0;)/m', 'opacity: 1;', $svg);
@@ -329,8 +329,9 @@ function echoAsPng(string $svg): void
329329
$imagick->setBackgroundColor(new ImagickPixel('transparent'));
330330

331331
// add svg image
332+
$imagick->setFormat('svg');
332333
$imagick->readImageBlob('<?xml version="1.0" encoding="UTF-8" standalone="no"?>' . $svg);
333-
$imagick->setImageFormat('png');
334+
$imagick->setFormat('png');
334335

335336
// echo PNG data
336337
header('Content-Type: image/png');

0 commit comments

Comments
 (0)