Skip to content

Bad conversion from SVG to PNG #371

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
roughnecks opened this issue Apr 14, 2025 · 0 comments
Open

Bad conversion from SVG to PNG #371

roughnecks opened this issue Apr 14, 2025 · 0 comments

Comments

@roughnecks
Copy link

ImageMagick version

8:6.9.11.60+dfsg-1.6+deb12u2

Operating system

Linux

Operating system, version and so on

Debian Stable (Bookworm)

Description

Hi,
if I load an svg file in a php script and convert it to png, the resulting image is broken, doesn't respect the original.

Steps to Reproduce

<?php

$svgFile = 'input.svg';
$outputPng = 'output.png';

try {

    $imagick = new Imagick();

    $imagick->setResolution(300, 300);

    $imagick->readImage($svgFile);

    $imagick->setImageFormat('png');

    $imagick = $imagick->flattenImages();

    $imagick->writeImage($outputPng);

    $imagick->clear();
    $imagick->destroy();

    echo "SVG converted to PNG successfully.\n";
} catch (Exception $e) {
    echo 'Error: ' . $e->getMessage() . "\n";
}
?>

Images

Image

Image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant