how to get svg containing colors and multiple paths

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?".
Locked
manit
Posts: 157
Joined: 2009-01-30T22:31:26-07:00

how to get svg containing colors and multiple paths

Post 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.

snibgo
Posts: 13034
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: how to get svg containing colors and multiple paths

Post 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.
snibgo's IM pages: im.snibgo.com

manit
Posts: 157
Joined: 2009-01-30T22:31:26-07:00

Re: how to get svg containing colors and multiple paths

Post 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.

snibgo
Posts: 13034
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: how to get svg containing colors and multiple paths

Post 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.
snibgo's IM pages: im.snibgo.com

manit
Posts: 157
Joined: 2009-01-30T22:31:26-07:00

Re: how to get svg containing colors and multiple paths

Post 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.

Locked