- Run a python script from Gimp Windows Python-Fu console
# get pwd
os.getcwd()
# run script
cat << EOF > myscript.py
import gimpfu
pdb.gimp_message("Hello world!")
img = gimp.image_list()[0]
print img
c = img.layers[0]
z = pdb.gimp_item_get_children(c)
for item in z:
print item
thisLayer = gimp.Item.from_id(item)
print thisLayer
# if thisLayer == 'titre':
EOF
execfile("myscript.py")
- Center and auto calculate grid /2
theImage = gimp.image_list()[0]
centerX = theImage.width/2
centerY = theImage.height/2
gridSpacing = max(theImage.width, theImage.height)/24
pdb.gimp_image_grid_set_offset(theImage, centerX, centerY)
pdb.gimp_image_grid_set_spacing(theImage, gridSpacing, gridSpacing)
pdb.gimp_image_grid_set_style(theImage, GRID_ON_OFF_DASH)
- Center and auto calculate grid x64
theImage = gimp.image_list()[0]
centerX = theImage.width/2
centerY = theImage.height/2
gridSpacing = max(theImage.width, theImage.height)/64
pdb.gimp_image_grid_set_offset(theImage, centerX, centerY)
pdb.gimp_image_grid_set_spacing(theImage, gridSpacing, gridSpacing)
pdb.gimp_image_grid_set_style(theImage, GRID_ON_OFF_DASH)
- Move image to absolute coordinates
x_new = 32
y_new = 64
img = gimp.image_list()[4]
layer = img.layers[4]
x_off, y_off = layer.offsets
#pdb.gimp_layer_translate(layer, x_new - x_off, y_new - y_off)
pdb.gimp_layer_set_offsets(layer, x_new, y_new)
- Get subitem (get children (like layer in grouplayer))
img = gimp.image_list()[0]
c = img.layers[0]
c
<gimp.Layer 'Layer Group'>
pdb.gimp_item_get_children(c)
(1, (4,))
c2 = gimp.Item.from_id(4)
c2
<gimp.Layer 'cam2'>
- Move group to absolute coordinates
x_new = 32
y_new = 64
img = gimp.image_list()[4]
#layer = img.layers[4]
x_off, y_off = layer.offsets
#pdb.gimp_layer_translate(layer, x_new - x_off, y_new - y_off)
pdb.gimp_layer_set_offsets(layer, x_new, y_new)
- Get layer (or group) coordinates
for layer in img.layers: print layer.offsets
c2 = gimp.Item.from_id(15)
pdb.gimp_layer_set_offsets(c2, 32, 64)