You are here

[solved] simple layer save script - what's wrong with it?

hi

i need to save all the layers as separate image files. i've written a simple python script to do that and it saves images, but every image contains only the first layer. here's the script:


#!/usr/bin/env python
from gimpfu import *
def python_pytest() :
  image = gimp.image_list()[0]
  # hiding all layers
  for layer in image.layers:
    pdb.gimp_layer_set_visible( layer, 0 )
  i=0
  # saving layers to files
  for layer in image.layers:
    #print 'layer:',layer
    pdb.gimp_layer_set_visible( layer, 1 )
    new_image = pdb.gimp_image_duplicate(image)
    drawable = pdb.gimp_image_get_active_drawable(new_image)
    pdb.gimp_file_save(1, new_image, drawable, '/home/tomek/image_layer_%02d.tga' % i, "")
    pdb.gimp_layer_set_visible( layer, 0 )
    i=i+1
  return


register(
       	"python_pytest",
	"Does something",
	"Does something terribly useful",
	"Your name",
	"Your name",
	"2009",
	"python_pytest",
	"*",
	[
	],
	[],
	python_pytest,
        menu="/Filters/Distorts")
main()

can anyone tell me why isn't it working?

edit: i've found a python script which does exactly what i want (after few modifications).

Hi,
>>> edit: i've found a python script which does exactly what i want (after few modifications). <<<
can you please tell the name of the script you use
thanks in advance
griessbx

Subscribe to Comments for "[solved] simple layer save script - what&#039;s wrong with it?"