Page 1 of 1

how to get svg containing colors and multiple paths

Posted: 2020-02-28T08:25:07-07:00
by manit
hi ,
I am using ImageMagick-7.0.9-26-portable-Q16-x64 on 64 bit windows 10 pro .
I want to draw a 'red cricket ball with white seam and transparent background' in svg so that its various image sizes are used in another image.
The following command draws the image as per my requirement :-
convert -size 100x100 xc:none -fill red -stroke black -strokewidth 4 -draw "path 'M 10,50 A 1,1 0 0,0 90,50 A 1,1 0 1,0 10,50 Z'" -strokewidth 3 -stroke white -fill red -draw "stroke-dasharray 7 3 path 'M 50,12 L 50,87'" path_circle.png
It looks like this https://ibb.co/K2dNRsV
Now, when I specify output as SVG using
convert -size 100x100 xc:none -fill red -stroke black -strokewidth 4 -draw "path 'M 10,50 A 1,1 0 0,0 90,50 A 1,1 0 1,0 10,50 Z'" -strokewidth 3 -stroke white -fill red -draw "stroke-dasharray 7 3 path 'M 50,12 L 50,87'" path_circle.svg
I find that svg file contains
<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20010904//EN"
"http://www.w3.org/TR/2001/REC-SVG-20010 ... /svg10.dtd">
<svg width="100" height="100">
stroke-dasharray:7 3 ; <path d="M 50,12 L 50,87"/>
</svg>
My question is
(1)As you can see only seam shape is present in svg and not the circle . How to have multiple paths in svg file ?
(2)Also there is no color detail in svg so when I do 'convert path_circle.svg -resize 1000x1000 big_ball.png' then I get an empty looking image.

Thanks.

Re: how to get svg containing colors and multiple paths

Posted: 2020-02-28T08:45:10-07:00
by snibgo
It seems IM will only give you the last path. So if you remove the second from your command, the SVG will contain the first.

Re: how to get svg containing colors and multiple paths

Posted: 2020-02-28T22:25:17-07:00
by manit
(1)Can I combine both paths into one , because I want SVG to contain circle and dotted line both ?
(2)Also how to save color info in svg ?

Thanks.

Re: how to get svg containing colors and multiple paths

Posted: 2020-02-29T06:34:34-07:00
by snibgo
Perhaps if you put all the IM vector operations into a single "-draw", it will create the SVG you want.

But it seems simpler just to write the SVG yourself.

Re: how to get svg containing colors and multiple paths

Posted: 2020-03-03T03:41:01-07:00
by manit
I could not find an example that combines both 'draw' .
Also , it seems that color is specified outside draw operator so it never enters svg file.