'''
Copyright (C) 2006 Aaron Spike, aaron@ekips.org
Copyright (C) 2010-2012 Nicolas Dufour, nicoduf@yahoo.fr
(Windows support and various fixes)
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
'''
# standard library
import os
import shutil
import sys
import tempfile
# local library
import inkex
# Define extension exceptions
dest="tab")
help="Save the Guides with the .XCF")
help="Save the Grid with the .XCF")
help="Add background color to each layer")
help="File resolution")
pass
# Create os temp dir (to store exported pngs and Gimp log file)
# Guides
hGuides = []
vGuides = []
# Grab all guide tags in the namedview tag
guideXpath = "sodipodi:namedview/sodipodi:guide"
if ori == '0,1':
# This is a horizontal guide
# GIMP doesn't like guides that are outside of the image
# The origin is at the top in GIMP land
elif ori == '1,0':
# This is a vertical guide
# GIMP doesn't like guides that are outside of the image
# Grid
gridSpacingFunc = ''
gridOriginFunc = ''
# GIMP only allows one rectangular grid
if gridNode != None:
# These attributes could be nonexistant
# Layers
area = '--export-area-page'
opacity = '--export-background-opacity='
opacity += "1"
else:
opacity += "0"
pngs = []
names = []
path = "/svg:svg/*[name()='g' or @style][@id]"
else:
command = "inkscape -i \"%s\" -j %s %s -e \"%s\" %s %s" % (id, area, opacity, filename, svg_file, resolution)
return_code = p.wait()
f = p.stdout
f.read()
f.close()
if return_code != 0:
else:
script_fu = """
(tracing 1)
(define
(png-to-layer img png_filename layer_name)
(let*
(
(png (car (file-png-load RUN-NONINTERACTIVE png_filename png_filename)))
(png_layer (car (gimp-image-get-active-layer png)))
(xcf_layer (car (gimp-layer-new-from-drawable png_layer img)))
)
(gimp-image-add-layer img xcf_layer -1)
(gimp-drawable-set-name xcf_layer layer_name)
)
)
(let*
(
(img (car (gimp-image-new 200 200 RGB)))
)
(gimp-image-set-resolution img %s %s)
(gimp-image-undo-disable img)
(for-each
(lambda (names)
(png-to-layer img (car names) (cdr names))
)
(map cons '(%s) '(%s))
)
(gimp-image-resize-to-layers img)
(for-each
(lambda (hGuide)
(gimp-image-add-hguide img hGuide)
)
'(%s)
)
(for-each
(lambda (vGuide)
(gimp-image-add-vguide img vGuide)
)
'(%s)
)
%s
%s
(gimp-image-undo-enable img)
(gimp-file-save RUN-NONINTERACTIVE img (car (gimp-image-get-active-layer img)) "%s" "%s"))
(gimp-quit 0)
""" % (self.options.resolution, self.options.resolution, filelist, namelist, hGList, vGList, gridSpacingFunc, gridOriginFunc, xcf, xcf)
f = p.stdin
return_code = p.wait()
if p.returncode != 0:
raise GimpXCFGimpNotInstalled
f.close()
# Uncomment these lines to see the output from gimp
#err = open(junk, 'r')
#inkex.debug(err.read())
#err.close()
try:
except:
raise GimpXCFScriptFuError
try:
import msvcrt
except:
pass
try:
finally:
x.close()
if __name__ == '__main__':
e = MyEffect()
e.affect()