From e8fd2d7e4dffd613e2c143539a0ab78fbe99e50e Mon Sep 17 00:00:00 2001 From: acspike Date: Mon, 11 Feb 2008 00:25:19 +0000 Subject: [PATCH] Update scriptfu from siod to tinyscheme I think this is a complete fix for the script but I can't tell because inkscape crashes. Intercepting the temporary file the script creates I get a complete layered xcf! --- share/extensions/gimp_xcf.py | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/share/extensions/gimp_xcf.py b/share/extensions/gimp_xcf.py index b7f0ff78f..7951ad190 100755 --- a/share/extensions/gimp_xcf.py +++ b/share/extensions/gimp_xcf.py @@ -37,7 +37,6 @@ class MyEffect(inkex.Effect): path = "/svg:svg/*[name()='g' or @style][@id]" for node in self.document.xpath(path,inkex.NSS): id = node.get('id') - inkex.debug(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) @@ -52,6 +51,7 @@ class MyEffect(inkex.Effect): namelist = '"%s"' % '" "'.join(names) xcf = os.path.join(tmp_dir, "%s.xcf" % docname) script_fu = """ +(tracing 1) (define (png-to-layer img png_filename layer_name) (let* @@ -69,14 +69,11 @@ class MyEffect(inkex.Effect): (img (car (gimp-image-new 200 200 RGB))) ) (gimp-image-undo-disable img) - (let* ((filelist '(%s))(namelist '(%s))) - (while filelist - (let* ((filename (car filelist))(layername (car namelist))) - (png-to-layer img filename layername) - ) - (set! filelist (cdr filelist)) - (set! namelist (cdr namelist)) + (for-each + (lambda (names) + (png-to-layer img (car names) (cdr names)) ) + (map cons '(%s) '(%s)) ) (gimp-image-resize-to-layers img) (gimp-image-undo-enable img) @@ -85,10 +82,14 @@ class MyEffect(inkex.Effect): """ % (filelist, namelist, xcf, xcf) junk = os.path.join(tmp_dir, 'junk_from_gimp.txt') - f = os.popen('gimp -i -b - > %s' % junk,'w') + f = os.popen('gimp -i --batch-interpreter plug-in-script-fu-eval -b - > %s 2>&1' % junk,'w') f.write(script_fu) f.close() - + # uncomment these lines to see the output from gimp + #err = open(junk, 'r') + #inkex.debug(err.read()) + #err.close() + x = open(xcf, 'r') sys.stdout.write(x.read()) x.close() -- 2.30.2