Conversion from svg to pdf results in a bitmap

Post any defects you find in the released or beta versions of the ImageMagick software here. Include the ImageMagick version, OS, and any command-line required to reproduce the problem. Got a patch for a bug? Post it here.
donovaly
Posts: 43
Joined: 2004-10-04T16:24:55-07:00

Conversion from svg to pdf results in a bitmap

Post by donovaly »

When I convert a svg-image to a pdf-image with the command

convert test.svg test.pdf

I get a bitmap image instead of a vector image. This destroys the advantage of svg's.

The resulting bitmap looks btw. very poor:

Test svg: http://fkurth.de/uwest/LyX/test.svg

Resulting pdf: http://fkurth.de/uwest/LyX/test.pdf
Resulting png: http://fkurth.de/uwest/LyX/test.png
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Post by magick »

ImageMagick rasterizes vector images. We have infastructure to retain vector information but its far from complete. In this case, you probably want to use a different program than ImageMagick.
donovaly
Posts: 43
Joined: 2004-10-04T16:24:55-07:00

Post by donovaly »

[quote="magick"]ImageMagick rasterizes vector images.ImageMagick.[/quote]

Hello magick,

thanks for the info. I could live with a raster image when it is in a viewable state. Have a look at the resulting png I postesd and compare it to the png that is produced when you convert the test.svg with e.g. Inkscape. It seems that Imagemagick just rasters them with a bad pixel resolution.
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Post by magick »

Try this command:
  • convert -density 300 test.svg test.png
donovaly
Posts: 43
Joined: 2004-10-04T16:24:55-07:00

Post by donovaly »

[quote="magick"]Try this command: [list]convert -density 300 test.svg test.png[/list][/quote]

This leads to a horrible output. When I try this with the test.svg I get huge letters displayed all over the place above the diagram. A bug I guess.
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Post by magick »

We got very good looking results. Does your version of ImageMagick include Freetype support? Type
  • idenitfy -list configure
to determine if its included. We're using ImageMagick 6.2.7-1.
donovaly
Posts: 43
Joined: 2004-10-04T16:24:55-07:00

Post by donovaly »

magick wrote: Does your version of ImageMagick include Freetype support? Type
  • idenitfy -list configure
to determine if its included. We're using ImageMagick 6.2.7-1.


I'm also using 6.2.7-1 but identify tells me that I have 6.2.4:

Name Value
-------------------------------------------------------------------------------
COPYRIGHT Copyright (C) 1999-2005 ImageMagick Studio LLC
HOST Windows
LIB_VERSION 0x624
LIB_VERSION_NUMBER 6,2,4,4
NAME ImageMagick
RELEASE_DATE 09/01/05
VERSION 6.2.4
WEBSITE http://www.imagemagick.org

the command:
convert -density 300 test.svg test.png

gives me this result:
http://james.physik.uni-freiburg.de/~stoehr/test.png
donovaly
Posts: 43
Joined: 2004-10-04T16:24:55-07:00

Post by donovaly »

Btw. Inkscape produces a correct output:
http://james.physik.uni-freiburg.de/~stoehr/foo.png

You can see that Imagemagick has also a problem with the image size when I use the -density option
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Post by magick »

If ImageMagick reports 6.2.4 that is the version you are using. You may have two versions of ImageMagick installed and are using the wrong one. When we convert your SVG with ImageMagick 6.2.7-1 we get the same results as you posted with Inkscape.
donovaly
Posts: 43
Joined: 2004-10-04T16:24:55-07:00

Post by donovaly »

[quote="magick"]If ImageMagick reports 6.2.4 that is the version you are using. You may have two versions of ImageMagick installed and are using the wrong one. When we convert your SVG with ImageMagick 6.2.7-1 we get the same results as you posted with Inkscape.[/quote]

Then you packed a wrong version to the 6.2.7-1 win-installer:

I deinstalled IM completely and also removed everything from the PATH and the registry and tried out the installer from different official mirrors. I always get

---------------------
C:\Documents and Settings\muso>identify -list configure

Path: C:\Program Files (x86)\ImageMagick-6.2.7-Q16\config\configure.xml

Name Value
-----------------------------------------------------------------------
COPYRIGHT Copyright (C) 1999-2005 ImageMagick Studio LLC
HOST Windows
LIB_VERSION 0x624
-----------------------------

but I also always get this:

-------------
C:\Documents and Settings\muso>identify -version

Version: ImageMagick 6.2.7 04/14/06 Q16 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2006 ImageMagick Studio LLC
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Post by magick »

You are correct. Unix automagically updates the configure information but a manual edit is required under Windows. Thanks for alerting us to this problem.
donovaly
Posts: 43
Joined: 2004-10-04T16:24:55-07:00

Post by donovaly »

magick wrote: You are correct. Unix automagically updates the configure information but a manual edit is required under Windows. Thanks for alerting us to this problem.


With the new IM 6.2.7-2 I got now a correct output for
identify -list configure
I also get now a nice looking png also without the -depth 300 option.
Many thanks for your prompt help!

There's now only one problem left: Converting the test.svg to ppm leads to a wrong output when the conversion is done directly with
convert test.svg test.ppm
This is what I get: http://fkurth.de/uwest/LyX/svg2ppm.ppm

When I convert the svg first to e.g. jpg and then to ppm I get a correct output:
http://fkurth.de/uwest/LyX/svg2jpg2ppm.ppm
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Post by magick »

JPEG is uses lossy compression so there are some differences in the output as expected. However, we can't identify what you are calling "wrong output." What about the direct conversion differs from that of first converting to JPEG?
donovaly
Posts: 43
Joined: 2004-10-04T16:24:55-07:00

Post by donovaly »

magick wrote: What about the direct conversion differs from that of first converting to JPEG?


I know that jpg uses lossy compression but jpg was only an example. Here you have the result when you first convert the svg to gif and then to ppm:
http://fkurth.de/uwest/LyX/svg2gif2ppm.ppm
magick wrote: What about the direct conversion differs from that of first converting to JPEG?


Load both files with e.g. Inkscape. You can see that the image svg2gif2ppm displays the graph and the direct svg2ppm image appears as black rectangle where you can't see anything.
The viewer program doesn't matter, I also get the same bad result when I open the images within LyX that uses a different ppm rendering engine than Inkscape. In LyX the direct svg2ppm is also unreadable.
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Post by magick »

Most likely the other programs can only display 8-bit PPM files. Try adding -depth 8 to your command line to produce acceptable PPM image files.
Post Reply