Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Convert SVG to JPEG with Imagemagick, missing external raster graphics

I would like to convert a simple svg graphic to a jpeg one. Here is the svg source code:

<svg style="overflow: hidden; position: relative;" 
  xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" 
  width="300" version="1.1" height="200">
     <image x="10" y="10" width="276" height="110" 
     xlink:href="http://images.google.com/intl/de_ALL/images/logos/images_logo_lg.gif"
     stroke-width="1"></image>
  <rect x="0" y="150" height="10" width="300" style="fill: #000000"/>
</svg>

If i do the conversion on my windows XP mashine with ImageMagick 6.7.8 all is working fine.

convert test.svg test.jpg

Conversion with windows

If i do the same conversion on my linux server (Debian 6.0 ImageMagick 6.6.0) get only the black line.

Conversion on linux server

I tried to upgrade to the latest Imagemagick version on my linux mashine but i get no newer version from the repository.

But i'm not sure if the use of external images is a feature from the newer version, or if it is a configuration issue.

Thanks for any suggestions!

like image 986
Michael Klenk Avatar asked Aug 09 '12 08:08

Michael Klenk


3 Answers

You might want to check your version with

convert --version

the following version happily does the intended conversion:

Version: ImageMagick 6.7.7-0 2012-05-27 Q16 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2012 ImageMagick Studio LLC
Features:  OpenCL

It is available in the current macports port.

This version:

Version: ImageMagick 6.6.9-7 2012-04-30 Q16 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2011 ImageMagick Studio LLC
Features: OpenMP   

In Ubuntu 12.04 LTS did not work ...

like image 163
Wolfgang Fahl Avatar answered Oct 24 '22 02:10

Wolfgang Fahl


@Wolfgang

I have almost the same verison of imagemagick as yours. (The release is not the same, but I don't think that will cause problem)

$ convert --version
Version: ImageMagick 6.6.9-7 2014-03-06 Q16 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2011 ImageMagick Studio LLC
Features: OpenMP 

And my system is :

Distributor ID: Ubuntu
Description:    Ubuntu-Secure-Remix 12.04.1 LTS 31.08.2012
Release:    12.04
Codename:   precise

I have tested in my system, it works well the command.

Or it exist another command :

rsvg-convert

It could be installed by type (in Ubuntu) :

apt-get install librsvg2-bin

And to convert a SVG to PNG, the command is :

rsvg-convert your_file.svg > your_file.png
like image 44
cupidcb Avatar answered Oct 24 '22 03:10

cupidcb


If there is no newer version in the Debian repository, your options are:

  1. Compile it yourself from the ImageMagick source code. Instructions are here.

  2. Install a pre-compiled non-Debian binary package (.tar.gz).

  3. Use Google and search for the official Debian Squeeze (a.k.a. 6.0) 'backport' repository. If you are lucky, there may be a newer ImageMagick available.

like image 34
Kurt Pfeifle Avatar answered Oct 24 '22 02:10

Kurt Pfeifle