Mobile app version of vmapp.org
Login or Join
LarsenBagley460

: Exporting an object from Inkscape with bounding box taken from another object I have a SVG file that contains a set of icons. For each icon there are two different objects in the SVG file.

@LarsenBagley460

Posted in: #Export #Inkscape #Svg

I have a SVG file that contains a set of icons.

For each icon there are two different objects in the SVG file. One is the icon itself (id=foo_icon), and a second is a solid white rectangle behind the icon that defines the bounding box (id=foo_box). This rectangle is solid (and not transparent) for easier handling within Inkscape.

I want to export each icon to PNG, with the correct bounding box, and with a transparent background. I would like to do this automatically, from a script.

I have tried the following:


inkscape -e foo_icon.png --export-id=foo_box icons.svg

This exports the icon with the correct bounding box, but the background is not transparent, because foo_box is exported and white.
inkscape -e foo_icon.png --export-id=foo_icon --export-id-only icons.svg

This exports the icon correctly, with transparent background, but the bounding box is not correct (it is taken from foo_icon, instead of foo_box).


Is there a way to achieve what I want? I need to tell Inkscape, for each icon ("foo"), to set the export area to the bounding box of foo_box, but only export foo_icon and hide all other objects.

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @LarsenBagley460

1 Comments

Sorted by latest first Latest Oldest Best

 

@Turnbaugh909

I can think of the following ways:


If your icons do not exceed their respective bounding boxes, delete all objects other than foo_box and foo_icon from the SVG with a script and then use --export-area-drawing:

inkscape -e foo_icon.png --export-id=foo_icon --export-id-only --export-area-drawing icons.svg

If your know the exact position of your bounding boxes, specify the export area manually (using --export-area=).
Use a script to temporarily edit the SVG to make the bounding box transparent.
Use a script to extract the size and position of the bounding box and specify the export area accordingly (using --export-area=).

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme