Drawing to svg doesn't seem to work right?

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
daviddoria

Drawing to svg doesn't seem to work right?

Post by daviddoria »

Taking an example from the help,

Code: Select all

convert -size 100x60 xc:skyblue -fill white -stroke black -draw "path 'M 30,40 A 30,20 20 0,0 70,20 A 30,20 20 1,0 30,40 Z '" arc.png
produces a bitmap with a blue background and a white ellipse with a black outline.

However, if you change the extension of the output

Code: Select all

convert -size 100x60 xc:skyblue -fill white -stroke black -draw "path 'M 30,40 A 30,20 20 0,0 70,20 A 30,20 20 1,0 30,40 Z '" arc.svg
convert arc.svg arc.png
I get a white background and a black ellipse.

What I am really trying to do is draw vector graphics on top of an existing bitmap image:

Code: Select all

convert myimage.png -fill white -stroke black -draw "line 0,0 100,30" output.svg
Anyone see where I am going wrong?

Thanks,

Dave
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Drawing to svg doesn't seem to work right?

Post by anthony »

If you are wanting to draw vector images on bitmaps, why are you saving as a vector image?



IM is not a vector image processor. yes it can read in vector image, but it can't true output vector images, only raster images embedded ina vector image.

See A word about Vector Image formats
http://www.imagemagick.org/Usage/formats/#vector

Somthing that I mention repeatedally on the forums.


SVG is even worse in that you can not even embed a raster image into that format.
however recent IM's will make use of the library "AutoTrace" (also a program). This program attempts to convert a raster into a vector image. For many images it works reasonably well with only some smoothing and distortion. But it will NEVER reproduce a true raster image.

See IM examples. SVG Output handling
http://www.imagemagick.org/Usage/draw/#svg_output

also a method of making use of that output to create smooth outlines from pure black and white bitmap images.
Edging using a Raster to Vector Converter
http://www.imagemagick.org/Usage/transform/#edge_vector

From this you should see IM does not do what you are expecting, as it is not a true vector image processor!
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
daviddoria

Re: Drawing to svg doesn't seem to work right?

Post by daviddoria »

Thanks Anthony. I did see a few notes about how it is not designed to do this, but it seems to be able to do almost everything else, so I thought there may be some 'workaround'! For anyone reading this - my next move is looking into inkscape's xml scripting for automatically drawing vector graphics (ie given a file full or coordinates, draw vector lines between them all).

Dave
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Drawing to svg doesn't seem to work right?

Post by anthony »

You may also like to look at the 'Fig' file format and the XFig or related client programs. It is in many ways similar to inkscape but with a much simpler and very well defined vector file format.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply