annotate transformations/gimp_script.py @ 7:f2d46bb3f2d5

Ajout de filtres GIMP (transformations/gimp_script.py)
author boulanni <nicolas_boulanger@hotmail.com>
date Tue, 26 Jan 2010 18:42:53 -0500
parents
children d511445f19da
rev   line source
7
f2d46bb3f2d5 Ajout de filtres GIMP (transformations/gimp_script.py)
boulanni <nicolas_boulanger@hotmail.com>
parents:
diff changeset
1 #!/usr/bin/env python
f2d46bb3f2d5 Ajout de filtres GIMP (transformations/gimp_script.py)
boulanni <nicolas_boulanger@hotmail.com>
parents:
diff changeset
2 # coding: utf-8
f2d46bb3f2d5 Ajout de filtres GIMP (transformations/gimp_script.py)
boulanni <nicolas_boulanger@hotmail.com>
parents:
diff changeset
3
f2d46bb3f2d5 Ajout de filtres GIMP (transformations/gimp_script.py)
boulanni <nicolas_boulanger@hotmail.com>
parents:
diff changeset
4 '''
f2d46bb3f2d5 Ajout de filtres GIMP (transformations/gimp_script.py)
boulanni <nicolas_boulanger@hotmail.com>
parents:
diff changeset
5 Exemple de script GIMP sous Python
f2d46bb3f2d5 Ajout de filtres GIMP (transformations/gimp_script.py)
boulanni <nicolas_boulanger@hotmail.com>
parents:
diff changeset
6 Auteur: Nicolas Boulanger-Lewandowski
f2d46bb3f2d5 Ajout de filtres GIMP (transformations/gimp_script.py)
boulanni <nicolas_boulanger@hotmail.com>
parents:
diff changeset
7 Date: Hiver 2010
f2d46bb3f2d5 Ajout de filtres GIMP (transformations/gimp_script.py)
boulanni <nicolas_boulanger@hotmail.com>
parents:
diff changeset
8
f2d46bb3f2d5 Ajout de filtres GIMP (transformations/gimp_script.py)
boulanni <nicolas_boulanger@hotmail.com>
parents:
diff changeset
9 usage:
f2d46bb3f2d5 Ajout de filtres GIMP (transformations/gimp_script.py)
boulanni <nicolas_boulanger@hotmail.com>
parents:
diff changeset
10 gimp -i --batch-interpreter python-fu-eval --batch - < gimp_script.py
f2d46bb3f2d5 Ajout de filtres GIMP (transformations/gimp_script.py)
boulanni <nicolas_boulanger@hotmail.com>
parents:
diff changeset
11
f2d46bb3f2d5 Ajout de filtres GIMP (transformations/gimp_script.py)
boulanni <nicolas_boulanger@hotmail.com>
parents:
diff changeset
12 Décommenter les lignes appropriées pour différents filtres
f2d46bb3f2d5 Ajout de filtres GIMP (transformations/gimp_script.py)
boulanni <nicolas_boulanger@hotmail.com>
parents:
diff changeset
13 Les plug-ins de GIMP et leurs paramètres sont disponibles sous GIMP, menu Help > Plug-in Browser (toujours ignorer le paramètre run-mode).
f2d46bb3f2d5 Ajout de filtres GIMP (transformations/gimp_script.py)
boulanni <nicolas_boulanger@hotmail.com>
parents:
diff changeset
14 Les autres fonctions du programme sont dans la Procedure DataBase (PDB) dans le menu Help > Procedure Browser.
f2d46bb3f2d5 Ajout de filtres GIMP (transformations/gimp_script.py)
boulanni <nicolas_boulanger@hotmail.com>
parents:
diff changeset
15 '''
f2d46bb3f2d5 Ajout de filtres GIMP (transformations/gimp_script.py)
boulanni <nicolas_boulanger@hotmail.com>
parents:
diff changeset
16
f2d46bb3f2d5 Ajout de filtres GIMP (transformations/gimp_script.py)
boulanni <nicolas_boulanger@hotmail.com>
parents:
diff changeset
17 from gimpfu import *
f2d46bb3f2d5 Ajout de filtres GIMP (transformations/gimp_script.py)
boulanni <nicolas_boulanger@hotmail.com>
parents:
diff changeset
18 import os, glob
f2d46bb3f2d5 Ajout de filtres GIMP (transformations/gimp_script.py)
boulanni <nicolas_boulanger@hotmail.com>
parents:
diff changeset
19
f2d46bb3f2d5 Ajout de filtres GIMP (transformations/gimp_script.py)
boulanni <nicolas_boulanger@hotmail.com>
parents:
diff changeset
20 filename = "images/*.jpg"
f2d46bb3f2d5 Ajout de filtres GIMP (transformations/gimp_script.py)
boulanni <nicolas_boulanger@hotmail.com>
parents:
diff changeset
21 folder = "out/"
f2d46bb3f2d5 Ajout de filtres GIMP (transformations/gimp_script.py)
boulanni <nicolas_boulanger@hotmail.com>
parents:
diff changeset
22
f2d46bb3f2d5 Ajout de filtres GIMP (transformations/gimp_script.py)
boulanni <nicolas_boulanger@hotmail.com>
parents:
diff changeset
23 filenames = glob.glob(filename)
f2d46bb3f2d5 Ajout de filtres GIMP (transformations/gimp_script.py)
boulanni <nicolas_boulanger@hotmail.com>
parents:
diff changeset
24 filenames.sort()
f2d46bb3f2d5 Ajout de filtres GIMP (transformations/gimp_script.py)
boulanni <nicolas_boulanger@hotmail.com>
parents:
diff changeset
25
f2d46bb3f2d5 Ajout de filtres GIMP (transformations/gimp_script.py)
boulanni <nicolas_boulanger@hotmail.com>
parents:
diff changeset
26 for fname in filenames:
f2d46bb3f2d5 Ajout de filtres GIMP (transformations/gimp_script.py)
boulanni <nicolas_boulanger@hotmail.com>
parents:
diff changeset
27 img = pdb.gimp_file_load(fname, fname)
f2d46bb3f2d5 Ajout de filtres GIMP (transformations/gimp_script.py)
boulanni <nicolas_boulanger@hotmail.com>
parents:
diff changeset
28 layer1 = img.active_layer
f2d46bb3f2d5 Ajout de filtres GIMP (transformations/gimp_script.py)
boulanni <nicolas_boulanger@hotmail.com>
parents:
diff changeset
29 img.disable_undo()
f2d46bb3f2d5 Ajout de filtres GIMP (transformations/gimp_script.py)
boulanni <nicolas_boulanger@hotmail.com>
parents:
diff changeset
30
f2d46bb3f2d5 Ajout de filtres GIMP (transformations/gimp_script.py)
boulanni <nicolas_boulanger@hotmail.com>
parents:
diff changeset
31 # Simple filters
f2d46bb3f2d5 Ajout de filtres GIMP (transformations/gimp_script.py)
boulanni <nicolas_boulanger@hotmail.com>
parents:
diff changeset
32 #pdb.plug_in_noisify(img, layer1, 0, 0.4, 0, 0, 0)
f2d46bb3f2d5 Ajout de filtres GIMP (transformations/gimp_script.py)
boulanni <nicolas_boulanger@hotmail.com>
parents:
diff changeset
33 #pdb.plug_in_c_astretch(img, layer1)
f2d46bb3f2d5 Ajout de filtres GIMP (transformations/gimp_script.py)
boulanni <nicolas_boulanger@hotmail.com>
parents:
diff changeset
34 #pdb.plug_in_emboss(img, layer1, 10, 30, 5, 0)
f2d46bb3f2d5 Ajout de filtres GIMP (transformations/gimp_script.py)
boulanni <nicolas_boulanger@hotmail.com>
parents:
diff changeset
35 pdb.plug_in_applylens(img, layer1, 2, 1, 0, 0)
f2d46bb3f2d5 Ajout de filtres GIMP (transformations/gimp_script.py)
boulanni <nicolas_boulanger@hotmail.com>
parents:
diff changeset
36 #pdb.plug_in_blur(img, layer1)
f2d46bb3f2d5 Ajout de filtres GIMP (transformations/gimp_script.py)
boulanni <nicolas_boulanger@hotmail.com>
parents:
diff changeset
37 #pdb.plug_in_gauss_rle(img, layer1, 9, 1, 0)
f2d46bb3f2d5 Ajout de filtres GIMP (transformations/gimp_script.py)
boulanni <nicolas_boulanger@hotmail.com>
parents:
diff changeset
38
f2d46bb3f2d5 Ajout de filtres GIMP (transformations/gimp_script.py)
boulanni <nicolas_boulanger@hotmail.com>
parents:
diff changeset
39 # More complex processing
f2d46bb3f2d5 Ajout de filtres GIMP (transformations/gimp_script.py)
boulanni <nicolas_boulanger@hotmail.com>
parents:
diff changeset
40 #layer2 = layer1.copy()
f2d46bb3f2d5 Ajout de filtres GIMP (transformations/gimp_script.py)
boulanni <nicolas_boulanger@hotmail.com>
parents:
diff changeset
41 #layer2.mode = MULTIPLY_MODE
f2d46bb3f2d5 Ajout de filtres GIMP (transformations/gimp_script.py)
boulanni <nicolas_boulanger@hotmail.com>
parents:
diff changeset
42 #img.add_layer(layer2, 0)
f2d46bb3f2d5 Ajout de filtres GIMP (transformations/gimp_script.py)
boulanni <nicolas_boulanger@hotmail.com>
parents:
diff changeset
43 #pdb.plug_in_solid_noise(img, layer2, 0, 0, 0, 8, 8, 8)
f2d46bb3f2d5 Ajout de filtres GIMP (transformations/gimp_script.py)
boulanni <nicolas_boulanger@hotmail.com>
parents:
diff changeset
44 #img.flatten()
f2d46bb3f2d5 Ajout de filtres GIMP (transformations/gimp_script.py)
boulanni <nicolas_boulanger@hotmail.com>
parents:
diff changeset
45 #layer1 = img.active_layer
f2d46bb3f2d5 Ajout de filtres GIMP (transformations/gimp_script.py)
boulanni <nicolas_boulanger@hotmail.com>
parents:
diff changeset
46
f2d46bb3f2d5 Ajout de filtres GIMP (transformations/gimp_script.py)
boulanni <nicolas_boulanger@hotmail.com>
parents:
diff changeset
47 fname2 = folder + '/' + os.path.basename(fname)
f2d46bb3f2d5 Ajout de filtres GIMP (transformations/gimp_script.py)
boulanni <nicolas_boulanger@hotmail.com>
parents:
diff changeset
48 pdb.gimp_file_save(img, layer1, fname2, fname2)
f2d46bb3f2d5 Ajout de filtres GIMP (transformations/gimp_script.py)
boulanni <nicolas_boulanger@hotmail.com>
parents:
diff changeset
49 print fname2
f2d46bb3f2d5 Ajout de filtres GIMP (transformations/gimp_script.py)
boulanni <nicolas_boulanger@hotmail.com>
parents:
diff changeset
50
f2d46bb3f2d5 Ajout de filtres GIMP (transformations/gimp_script.py)
boulanni <nicolas_boulanger@hotmail.com>
parents:
diff changeset
51 pdb.gimp_quit(0)