我试图写一个脚本, 将一个层切成小和平。 它运行正确, 但没有什么被粘贴到一个新的层 。
def explode_layer( i, l, dx, dy ):
T=[]
for ix,ox in enumerate(range(l.offsets[0], l.offsets[0]+l.width, dx )):
for iy,oy in enumerate(range(l.offsets[1], l.offsets[1]+l.height, dy)):
pdb.gimp_rect_select(i, ox, oy, dx, dy, 2, False, 0)
if not pdb.gimp_edit_copy(l):
continue
layer = pdb.gimp_layer_new(i, dx, dy, 1,
l.name+" %d,%d"%(ix,iy), 100, 0)
i.add_layer(layer)
floating_sel = pdb.gimp_edit_paste(layer, True)
pdb.gimp_layer_set_offsets(floating_sel, *layer.offsets)
pdb.gimp_floating_sel_anchor(floating_sel)
T.append(layer)
return T
I use gimp 2.6.8 on Ubuntu 10.04. How can I fix it? Is there a better approach?