Page 1 of 1

SVG display:none or other ways to hide things

Posted: 2010-05-07T07:28:42-07:00
by bmearns
Is there any way to hide SVG elements so they are not visible in IM generated images? The standard way to hide things in SVG I think is with style="display:none". I've also tried style="visibility:hidden", but either way the element still shows up in images produced by IM.

The command I'm using is simply:

Code: Select all

convert image.svg image.png
The reason for wanting to do this is that I have a number of different "decorations" on my image, and I want to have different ones visible in different outputs. I don't want to delete the elements from the image because I will need them again sometime, and I'd don't want to have multiple copies of the SVG image because most of the image is the same across all variations, so I don't want to have to update it in multiple places.

Re: SVG display:none or other ways to hide things

Posted: 2010-05-07T09:04:12-07:00
by snibgo
You might find that Inkscape is better at obeying SVG styles:

Code: Select all

inkscape -f in.svg -e out.png -y 1

Re: SVG display:none or other ways to hide things

Posted: 2010-05-07T09:45:16-07:00
by bmearns
Interesting, thank you snibgo. I didn't realize inkscape did stuff from the command line. Unfortunately, it's a bit wonky on windows at least; it looks like it requires absolute paths or else they are taken relative to the directory where the inkscape executable is. But a little makefile magic will take care of it.

Code: Select all

LOCAL_DIR=$(dir $(realpath $(lastword $(MAKEFILE_LIST))))

%.png : %.svg
	inkscape "$(LOCAL_DIR)$^" -e "$(LOCAL_DIR)$@