Andrés Smerkin
Andrés Smerkin

Reputation: 177

How can i convert a svg image to png image with Imagemagick when the svg file has embedded images?

With PHP i'm creating an image with embedded content (base64 encoded files). If i see it using Firefox, or downloading it and then opening it with Inkscape (www.inkscape.org), the image is fine!.

But when i try to convert it using imagemagick (using convert command or with Imagick support for PHP) the embedded image doesn't come in with the final result.

I don't know if there is a special command or configuration i'm missing. I'm not using any special setup. Just ...

convert image.svg image.png 

Thank you very much for your answer.

Upvotes: 2

Views: 2625

Answers (2)

Ilmari Karonen
Ilmari Karonen

Reputation: 50328

ImageMagick's built-in SVG rendering is really pretty horrible. Don't use it if you can avoid it. I'd recommend using librsvg instead, either using the command-line rsvg tool, or possibly with the PHP rsvg extension.

(Librsvg's rendering isn't always perfect either, but it should be able to handle embedded images just fine. If you want even better rendering, you could always try using Inkscape from the command line.)

Upvotes: 3

PhiLho
PhiLho

Reputation: 41132

Is the embedded image in PNG or in Jpeg format? What converter is used in PHP? I tried on Windows with latest ImageMagick, which doesn't come with RSVG. I found a RSVG-Converter build for Windows, and, while it does a good job, it skips the Jpeg version of the image of a test file.

On the other hand, the built-in converter handles correctly both images, but does an awful job on the home image shown in the SVG tutorial.

Upvotes: 1

Related Questions