I made a script for importing gimp image file (xcf), you can import the flatened image or one image per layer.
You need to install xcftools (http://henning.makholm.net/software), i m afraid its linux only. If someone knows a similar tool for windows or mac i can adapt the script.
#!BPY
"""
Name: 'Gimp (xcf)...'
Blender: 245
Group: 'Import'
Tooltip: 'Import gimp xcf with layers'
"""
__author__= ['Victor Barberan']
__url__ = (' ')
__version__= '0.1'
__bpydoc__= '''
Import Gimp xcf format.
This script requires xcftools (http://henning.makholm.net/software).
'''
# ***** BEGIN GPL LICENSE BLOCK *****
#
# This program is free software; you can redistribute it and/or
# modify 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
# ***** END GPL LICENCE BLOCK *****
# --------------------------------------------------------------------------
import Blender, commands, os
from Blender import *
xcfinfo = 'xcfinfo'
xcf2png = 'xcf2png'
flat = True
#load xcf file
def load_gimp(xcf_path):
xcf_file = Blender.sys.basename(xcf_path)
tempdir = Get('tempdir')
if flat:
#convert flatened xcf
xcf_png = tempdir+xcf_file[:-4]+'.png'
out = commands.getoutput(xcf2png+' "'+xcf_path+'" -T -o "'+xcf_png+'"')
#check if image was generated
if not os.path.exists(xcf_png):
Draw.PupMenu('Error importing file...%t| Do you have xcftools instaled??')
return None
#import image
newImg = Image.Load(xcf_png)
newImg.name = xcf_file[:-4]
newImg.makeCurrent()
Draw.Redraw()
if os.path.exists(xcf_png): os.remove(xcf_png)
else:
#get info of the xcf file
info = commands.getoutput(xcfinfo+' '+'"'+xcf_path+'"')
print info
#check if info was generated
if 'not found' in info:
Draw.PupMenu('Error importing file...%t| Do you have xcftools instaled??')
return None
#get number of layers
layer_num = int(info.splitlines()[0].split(',')[2].strip('layers').strip())
layer_names = []
#get layer names and put in a list
for n in range(layer_num):
names = info.splitlines()[n+1].split(' ')[4:]
name = ''
for n in names:
name += n+' '
layer_names.append(name.strip())
#convert every layer to png, and import it
for layer in layer_names:
#generate png image
layerpng = tempdir+layer.strip('"')+'.png'
out = commands.getoutput(xcf2png+' "'+xcf_path+'" "'+layer+'" -T -o "'+layerpng+'"')
#check if image was generated
if not os.path.exists(layerpng):
Draw.PupMenu('Error importing file...%t| Do you have xcftools instaled??')
return None
#import image
newImg = Image.Load(layerpng)
newImg.name = xcf_file+': '+layer
if os.path.exists(layerpng): os.remove(layerpng)
newImg.makeCurrent()
Draw.Redraw()
if __name__=='__main__':
ask = Draw.PupMenu('How do you like to import the Gimp file?%t| Flatened layers %x1| One image per layer%x2')
if ask == 1:
flat = True
Window.FileSelector(load_gimp, 'Import Gimp', '*.xcf')
elif ask == 2:
flat = False
Window.FileSelector(load_gimp, 'Import Gimp', '*.xcf')
Copy the script to your blender scripts directory, and it should appear in the file->import menu.
Hope someone finds it useful.
sorry for my bad english.
vico