Page 1 of 1

Images embedded in svg are broken into une circle per pixell

Posted: 2014-06-09T14:40:04-07:00
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.

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

Posted: 2014-06-09T14:43:54-07:00
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

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

Posted: 2014-06-09T14:51:56-07:00
by teo8976
Then why does it support svg and pdf formats?

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

Posted: 2014-06-09T15:49:29-07:00
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.

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

Posted: 2014-06-09T16:43:13-07:00
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.

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

Posted: 2014-06-09T17:50:27-07:00
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.

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

Posted: 2014-06-09T18:33:30-07:00
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