Convert SVG to JPEG with Imagemagick, missing exte

2019-04-28 13:51发布

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!

4条回答
爷的心禁止访问
2楼-- · 2019-04-28 14:30

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.

查看更多
Luminary・发光体
3楼-- · 2019-04-28 14:32

You may also try Apache Batik SVG Rasterizer

java -jar batik-rasterizer.jar samples/batikFX.svg

It does fetch external images.

查看更多
何必那么认真
4楼-- · 2019-04-28 14:34

@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
查看更多
Emotional °昔
5楼-- · 2019-04-28 14:50

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 ...

查看更多
登录 后发表回答