Frame by frame animation extension in development

Other sites and resources for Inkscape users.
natorx
Posts: 6
Joined: Sun Sep 12, 2010 11:41 am

Frame by frame animation extension in development

Postby natorx » Sun Sep 12, 2010 1:02 pm

I have been working all week on an extension to import a series of pencil sketch frames into layers which I can then ink and paint in Inkscape. I am also working on an extension to output those inked layers into a series of frames. I usually create my frames in Pencil http://www.pencil-animation.org/ and wanted a better way to ink them. So I started coding. Python coding is brand new to me. I mostly used bash scripting before now.

My input plugin was based on the Hello World example extension. I have this extension working but I'd like to iron it out. Plus Inkscape wasn't made to handle hundreds of bitmap images.

My output plugin is being based on Chris McCormick's GIFanimate extension http://mccormick.cx/news/entries/inkscape-animation.news and the Gimp XCF layers extension. This extension likes to crash Inkscape and I can only get it to output to the /tmp directory.

Anyway, I'd like to release them together once I get them both working. I was wondering if this was a good place to post questions about extension development or would another forum section or another website be more helpful? I'm also trying to find out if anyone would even be interested in using such an extension.

Edit:
I have a working version now. https://code.google.com/p/inkscape-animation-extension/ You can download it here.
Update:
I uploaded version 0.4 code and added a download link to the google code site.
Last edited by natorx on Tue Dec 23, 2014 12:15 pm, edited 3 times in total.

~suv
Posts: 2272
Joined: Sun May 10, 2009 2:07 am

Re: Frame by frame animation extension in development

Postby ~suv » Sun Sep 12, 2010 3:38 pm

natorx wrote:My output plugin is being based on Chris McCormick's GIFanimate extension http://mccormick.cx/news/entries/inksca ... ation.news and the Gimp XCF layers extension. This extension likes to crash Inkscape and I can only get it to output to the /tmp directory.

The extension 'GIFanimate' seems based on an outdated "Hello World" example [1]. I don't know however what causes Inkscape to crash, if you use the extension as is. Can you paste the error message here? Also, does Inkscape itself crash or does the extension fail and return a python error message?

Take a look at the "Hello World" example [2] in Inkscape's Wiki, and at the other extensions that ship with Inkscape [url]0.47[/url] or 0.48. You might also reuse the bundled helper extension launch_webbrowser.py to open the created GIF file in the web browser.


[1] Inkscape and the script library module inkex.py no longer use python-xml, but lxml instead.
[2] the example in the Wiki is based on the state of the script extensions implementation of Inkscape 0.46. There have been minor changes to the INX format in Inkscape 0.47 you can easily detect by comparing it to those that ship with Inkscape (summary of the changes for 0.47: "All extensions are now propper XML files with a namespace and all validate against the new inkscape.extension.rng RelaxNG schema.")
Last edited by ~suv on Sun Sep 12, 2010 4:16 pm, edited 3 times in total.

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

Re: Frame by frame animation extension in development

Postby brynn » Sun Sep 12, 2010 3:48 pm

OMG, I would love to have such an extension to use!

You will probably get some good input from this forum, although it's a bit over my head. But you might also want to join the developers' mailing list. There you could get some very technical discussion, which might be more useful as far as coding. Have a look at this page http://wiki.inkscape.org/wiki/index.php/Inkscape I think you will find some very helpful info and resources. Somewhere on that site you can find the mailing list address, or maybe someone else will post it here.

OR -- I don't know if you're aware that animation support is planned for Inkscape, although I don't think anytime soon. Your extension would still be helpful in the meantime though. But maybe you would want to participate in development, in the long run? Just a thought :D

Off topic:
~suv sneaks another reply in while I'm typing, lol!

~suv
Posts: 2272
Joined: Sun May 10, 2009 2:07 am

Re: Frame by frame animation extension in development

Postby ~suv » Sun Sep 12, 2010 4:38 pm

natorx wrote:My output plugin (…) and I can only get it to output to the /tmp directory.

Extensions in general do not know the path of the document they have been called from, and can't reuse it as path for the output files. For output extensions (via 'File > Save a Copy…'), Inkscape takes care of this. Effect extensions otoh, run from the 'Extensions' menu, do need to prompt the user for the path if needed (or e.g. can make use - if present - of 'export-hints' as stored in the SVG source by the 'File > Export Bitmap… command).

Maybe of interest:
  • 'GIMP XCF maintaining layers' output extension (Inkscape)
    exports layers to PNG, calls GIMP on the command line to import the PNGs as layers in XCF
  • 'Images > Extract Images…' effect extension (Inkscape)
    how to access other locations than $TMP
  • 'Inkscape-Slicer' effect extension (external)
    also an example to write the output to custom locations set by the user in the extension dialog
  • 'Guillotine' effect extension to export PNG slices defined by guides (New in Inkscape 0.48+devel)
    makes use of 'export-hints' as path for the newly created PNG slices
  • 'JessyInk' extension for creating presentations (New in Inkscape 0.48)
    includes output extension to export layers to PDF or PNG (as zipped archive)

~suv
Posts: 2272
Joined: Sun May 10, 2009 2:07 am

Re: Frame by frame animation extension in development

Postby ~suv » Sun Sep 12, 2010 6:21 pm

natorx wrote:This extension likes to crash Inkscape (…)
~suv wrote:I don't know however what causes Inkscape to crash, if you use the extension as is. Can you paste the error message here? Also, does Inkscape itself crash or does the extension fail and return a python error message?

Ok, I get the same crashes (of Inkscape itself), testing GIFanimate.py in Inkscape 0.48 and 0.48+devel on OS X 10.5.8. The crash seems related to the system calls, already triggered by the first one on line 31

Code: Select all

        [os.system(pngcommand % (infile, id, id)) for id in layerids]

If I comment that line and the other system commands out, and return the commands as strings to Inkscape (using 'inkex.errormsg' instead of 'os.system') Inkscape does not crash when the extension finishes. If I subsequently uncomment line 31 only, the export of each of the layer PNGs works, but Inkscape crashes when the extension finishes. Possibly the crash is caused by a change in how the current extension system spawns processes (?) and the script has to use pipes for system commands which have to be closed after each call.

Excerpts from 'gimp_xcf.py' (shipped with 0.48):

Code: Select all

try:
    from subprocess import Popen, PIPE
    bsubprocess = True
except:
    bsubprocess = False

Code: Select all

        area = '--export-area-page'
        pngs = []
        names = []
        path = "/svg:svg/*[name()='g' or @style][@id]"
        for node in self.document.xpath(path, namespaces=inkex.NSS):
            id = node.get('id')
            name = "%s.png" % id
            filename = os.path.join(tmp_dir, name)
            command = "inkscape -i %s -j %s -e %s %s " % (id, area, filename, svg_file)
            if bsubprocess:
                p = Popen(command, shell=True, stdout=PIPE, stderr=PIPE)
                return_code = p.wait()
                f = p.stdout
                err = p.stderr
            else:
                _,f,err = os.popen3(command,'r')
            f.read()
            f.close()
            err.close()
            pngs.append(filename)
            names.append(id)

        filelist = '"%s"' % '" "'.join(pngs)
        namelist = '"%s"' % '" "'.join(names)


Maybe this helps to rewrite the export function (to put the 'popen' command inside the loop going through all layers) to avoid Inkscape crashing like this:

Code: Select all

terminate called after throwing an instance of 'Inkscape::Extension::Input::open_failed'
  what():  Open failed

natorx
Posts: 6
Joined: Sun Sep 12, 2010 11:41 am

Re: Frame by frame animation extension in development

Postby natorx » Tue Sep 14, 2010 9:18 am

Thanks, suv. This helps alot. I'm going to add this in tonight. I might even be close to my first release if I can get it functioning.

natorx
Posts: 6
Joined: Sun Sep 12, 2010 11:41 am

Re: Frame by frame animation extension in development

Postby natorx » Wed Sep 15, 2010 4:55 am

I have a working version now. https://code.google.com/p/inkscape-animation-extension/ You can download it here.
The main feature I'm still working on is a way to hide/show sub-layers. I uploaded it to google code because I saw a few other inkscape extension projects on there but I'm not really sure how subversion works.
Anyway, you can try it out. Please feel free to give any type of comments.
I think I'll spend some time working on my animation now. It will be a good example of what the extension can do.

natorx
Posts: 6
Joined: Sun Sep 12, 2010 11:41 am

Re: Frame by frame animation extension in development

Postby natorx » Mon Sep 20, 2010 1:22 pm

http://code.google.com/p/inkscape-animation-extension/downloads/list
I have a new version up now. I've been working all week to get some new features working. I think it is at a point now where I can use it to get work done. It can import frames and output frames. I added the extension to hide and lock frame layers and sub-layers. My biggest issue now is that Inkscape cannot handle more than about 50 frame layers on my computer. If I have too many frame layers the hide/lock and output extensions freeze Inkscape.

Thanks again for the info. It is not easy to find information on coding extensions.

procastino
Posts: 34
Joined: Tue Jan 08, 2008 10:20 pm

Re: Frame by frame animation extension in development

Postby procastino » Fri Feb 11, 2011 8:07 am

I've just downloaded your extension, and I'm grateful for it. I'm planning an animation and being able to export layers easily is really what I need, I'll tell you how it goes.

User avatar
javierdl
Posts: 38
Joined: Sat Aug 25, 2007 4:45 am
Location: Montreal
Contact:

Re: Frame by frame animation extension in development

Postby javierdl » Thu Dec 27, 2012 7:14 am

Happy Holidays everyone!
Hey natorx, what ever happened to your promissing animation extension? Did you halt the dev? If so, would you mind sharing what animation set up you found to work for you? (programs and procedure, assuming you're still animating)

I'm just looking into setting this up for the first time, so I could use some recommendations/tips/advice . I'm quite comfortable with Inkscape & Gimp, and I just installed Synfig (but haven't tried it yet). From what I've read about Synfig it sounds like it's just what I need.

Thanks in advance,

JDL

jabiertxof
Posts: 184
Joined: Wed Feb 06, 2013 6:47 am

Re: Frame by frame animation extension in development

Postby jabiertxof » Fri Feb 08, 2013 10:30 pm

Great extension.
I have an idea, another option in the extensions group to made Onion Skin from current layer.
Inputs:
Number back onions layers
Number front onions layers (mayber the same, or switch to hide front onions layer)
Undone. maybe custom options to sweet diferent undone options. Like show all backgrounds and remove opacity to all layers.
When aply, add full opacity to all main layers except no opacity for current main layer and progresive opacity for the previous and the next layers. Ofcourse it hides the background
If you want i could help!

Hi and sorry for my english, Jabier.

natorx
Posts: 6
Joined: Sun Sep 12, 2010 11:41 am

Re: Frame by frame animation extension in development

Postby natorx » Wed Jul 16, 2014 8:42 am

Version 0.3 release:
I know it has been quite a long time. I'm sorry. I have since learned a few things about programming which has helped.

I updated the scripts to use some of the lxml features in hopes that it would speed up the extension. It outputs images faster than before but still seems to hang after the script has finished processing. I believe the problem is that Inkscape struggles to reload the file after the extension finishes. I will keep looking into a solution.

I also added some SMIL animation attributes to the layers. This allows you to preview your animation in any compatible web browser like Firefox. Here is an example:
Image

There is also an option to display the frame number in the upper left corner of every frame.

Please enjoy.

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

Re: Frame by frame animation extension in development

Postby brynn » Wed Jul 16, 2014 6:16 pm

Looks exciting!

natorx
Posts: 6
Joined: Sun Sep 12, 2010 11:41 am

Re: Frame by frame animation extension in development

Postby natorx » Tue Dec 23, 2014 12:03 pm

I updated the animation extension for the upcoming 0.91 release. There was an issue with changes to units and the viewbox.
https://code.google.com/p/inkscape-animation-extension/

I think this will be the last update I make for this extension. I have hit a wall trying to find a way to speed up the extension when dealing with many frames. The issue lies in the way extensions have been implemented in Inkscape. The way I understand it, extensions take a copy of the current document and apply changes to the copy. When an extension is done, Inkscape loads the copy with any changes applied. This loading seems to be the cause of the slowdown when dealing with so many frame layers. My assumption is that if my extension were able to edit the document in memory directly there would be significantly less slowdown.

Instead I will focus my efforts on implementing an animation panel within Inkscape. It may take some time but it should be worth it to improve animation usability. I like the panel on this page but I have some other ideas that might help animators that normally animate to a specific frame rate. http://wiki.inkscape.org/wiki/index.php/SpecSVGAnimation I think my vision has many similarities to Synfig but will be more compliant to the SVG standard. I want to be able to load these animations in a web browser like any other Inkscape document. Synfig seems to be focused only on outputting rendered frames.

Hopefully, I can figure out all of this GTK stuff.

tinahilton
Posts: 8
Joined: Tue Jan 06, 2015 10:50 am
Location: USA
Contact:

Re: Frame by frame animation extension in development

Postby tinahilton » Tue Jan 06, 2015 11:36 am

Good job ! I love it
My Blog : Free Vector Art


Return to “Inkscape Resources”