Exporting specially named groups as multiple formats

Discussion about writing code for Inkscape.
nalaurethsulfate
Posts: 4
Joined: Fri Mar 15, 2013 1:06 am

Exporting specially named groups as multiple formats

Postby nalaurethsulfate » Fri Mar 15, 2013 1:12 am

Hi all,
Pretty new here, though I've been using inkscape for some time.

Recently I was looking for something to keep a "master image" of sorts for an entire chapter of say a book, and then be able to automatically export the pictures that make up that chapter as different formats. I couldn't find anything, well I found one thing that sort of worked, but was a hassle to use and only exported .png (although it was easily modded to allow for eps). So I wrote this small script which should be fairly self explanatory and posted it here.

I'm new to this whole thing though so I would love feedback, and also it may be useful to some of you.

Jelle
Posts: 78
Joined: Sat Nov 06, 2010 11:25 am

Re: Exporting specially named groups as multiple formats

Postby Jelle » Fri Mar 29, 2013 5:57 pm

Hi nalaurethsulfate ;-)

Interestingly there was a discussion on the developers list recently on this topic. Unfortunately it stranded in bickering about save v.s. export, but the basic idea that the current export to .png could easily be extended to all other formats supported by Inkscape stands vindicated by what you did I guess. If you be interested in extending your work so all exports could be handled by the same mechanism I am sure it would be a great improvement for Inkscape. I personally see any format that is not Inkscape native as an export, but better not mention that concept.. lol. Being able to export a group or selection or area to any given format would be a great tool and highly useful for everybody.

In any case I think you might want to discuss your script on the developers list for more insightful feedback. I personally like it a lot already, but would like to see it extended to more supportable formats.

nalaurethsulfate
Posts: 4
Joined: Fri Mar 15, 2013 1:06 am

Re: Exporting specially named groups as multiple formats

Postby nalaurethsulfate » Sat Mar 30, 2013 1:27 am

Thanks Jelle!
I like your ideas and would love to start hacking away on inkscape itself, but unfortunately will not have the time to do so for at least the next month.

As far as more supportable formats, it is incredibly simple to extend to any that have the api call that respects "--export-id" and that has an --export-"type"="filename" in the API. I think this supports all of those formats, and certainly covers many bases. More formats might require more inkscape scripting, which sucks, and has to open the window every time (I did it for the plain svg export), but it really is terrible.

Anyways I will probably post this on the forums because the whole export vs. saving thing could probably use some more hashing out :s

User avatar
brynn
Posts: 10309
Joined: Wed Sep 26, 2007 4:34 pm
Location: western USA
Contact:

Re: Exporting specially named groups as multiple formats

Postby brynn » Sun Mar 31, 2013 12:55 am

nalaurethsulfate wrote:Anyways I will probably post this on the forums because the whole export vs. saving thing could probably use some more hashing out :s

If you want to have this discussion with developers, this forum would probably not be the best place to do it, since not many devs participate here. Of course you're welcome to start such a discussion, but you probably won't get many devs' attention or participation here. ;)

User avatar
ragstian
Posts: 1181
Joined: Thu Oct 11, 2012 2:44 am
Location: Stavanger-Norway

Re: Exporting specially named groups as multiple formats

Postby ragstian » Sun Mar 31, 2013 8:32 am

Hi nalaurethsulfate

Nice code!
Found I had to install lxml and svgfig to get it to work.

RGDS
Ragnar
Good Luck!
( ͡° ͜ʖ ͡°)
RGDS
Ragnar

nalaurethsulfate
Posts: 4
Joined: Fri Mar 15, 2013 1:06 am

Re: Exporting specially named groups as multiple formats

Postby nalaurethsulfate » Sun Mar 31, 2013 10:16 am

Oh, I should have stated that in the readme

User avatar
ragstian
Posts: 1181
Joined: Thu Oct 11, 2012 2:44 am
Location: Stavanger-Norway

Re: Exporting specially named groups as multiple formats

Postby ragstian » Sun Mar 31, 2013 11:44 am

Hi

I find that I have to close Inkscape manually every time it's opened by your script - is this intentional?
Inkscape also "complains" a lot about missing fonts when running your script - how can that be avoided?

RGDS
Ragnar
Good Luck!
( ͡° ͜ʖ ͡°)
RGDS
Ragnar

nalaurethsulfate
Posts: 4
Joined: Fri Mar 15, 2013 1:06 am

Re: Exporting specially named groups as multiple formats

Postby nalaurethsulfate » Mon Apr 01, 2013 6:30 am

On my computer it works as described, without having to manually close, and with no complaints about missing fonts.

Have you tried it with one of your own svg's? If that doesn't fix both problems try another script that just opens and closes inkscape, you should be able to hijack that code from my script easily.

Other than that I'm not sure what to tell you and don't have too much time to play with this for a while.


Return to “Programming”