Images embedded in svg are broken into une circle per pixell

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.
Post Reply
teo8976
Posts: 3
Joined: 2014-06-09T14:32:59-07:00
Authentication code: 6789

Images embedded in svg are broken into une circle per pixell

Post by teo8976 »

Steps to reproduce:
1) convert someimage.png output.svg

or
2) convert somepdf.pdf output.svg
where the pdf contains embedded images.

Expected: the image/s should be embedded in the svg in the form <image xlink:href="data:image/png;base64,iVBORw0KGgo........" etc>

Observed: every pixel of the image is converted into a circle of 1px diameter. EVEN in the case of the pdf. if the images are not very tiny, you end up with a gigantic svg file.

Compare this to the behavior of Inkscape: if you import an image into inkscape and save as svg, the image is embedded as expected. And if you import a pdf into inkscape and save as svg, too.

Breaking the image into per-pixel 1-px circles may be an interesting possibility to have available as an option, but it shouldn't be the default behavior, it's insane in most cases.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Images embedded in svg are broken into une circle per pi

Post by fmw42 »

Imagemagick is not a good tool to use for vector processing. It is a raster tool. It will not vectorize a raster image properly. You need to find some other tool for that. see http://www.imagemagick.org/Usage/formats/#vector
teo8976
Posts: 3
Joined: 2014-06-09T14:32:59-07:00
Authentication code: 6789

Re: Images embedded in svg are broken into une circle per pi

Post by teo8976 »

Then why does it support svg and pdf formats?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Images embedded in svg are broken into une circle per pi

Post by fmw42 »

teo8976 wrote:Then why does it support svg and pdf formats?

Mostly to convert them to raster formats. I do not think that IM supports embedding the raster image directly into an svg shell at this time.
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Images embedded in svg are broken into une circle per pi

Post by magick »

We'll get a patch in ImageMagick 6.8.9-4 to create the SVG with an inline image. Thanks for the suggestion.
teo8976
Posts: 3
Joined: 2014-06-09T14:32:59-07:00
Authentication code: 6789

Re: Images embedded in svg are broken into une circle per pi

Post by teo8976 »

Ok, I've now read the note that explains that imagemagick rasters everything forth and back, so I'm simply using the wrong tool anyway (I wrongly thought vectors would be maintained in vector-vector conversions - I seemed to remember I had used IM before for such tasks, I was confused, I must have used something else). Sorry.

Inline images would be an improvement, however. In those cases where one just needs a quick hack to get a given output format (e.g. svg or pdf) and doesn't care very much about the loss of information implicit in rasterizing everything in the process, that will make the difference between ending up with a manageable file of a reasonable size or an unmanageable GB file.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Images embedded in svg are broken into une circle per pi

Post by fmw42 »

Autotrace or Potrace can vectorize images. I believe if autotrace is installed, IM can use it. Though I believe only for b/w images. see http://www.imagemagick.org/Usage/draw/#svg_output
Post Reply