SVG display:none or other ways to hide things

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
bmearns

SVG display:none or other ways to hide things

Post 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.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

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

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

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

Post 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)$@
Post Reply