Skip to content

Instantly share code, notes, and snippets.

@tuaplicacionpropia
Created June 30, 2018 07:59
Show Gist options
  • Save tuaplicacionpropia/49a71d5a0ebaab35db04275969bcdd3e to your computer and use it in GitHub Desktop.
Save tuaplicacionpropia/49a71d5a0ebaab35db04275969bcdd3e to your computer and use it in GitHub Desktop.
GIMP Plugin: Enfocar
#!/usr/bin/env python
'''
Ok I finally got it working. I used the GIMP Python scripting to create a gimp plugin which can do a tonne of stuff including the layers you mentioned. Then you can just run gimp from the command line passing arguments to the python gimp script. The article Using Python-Fu in Gimp Batch Mode was an excellent resource for learning how to call gimp plugins from the command line. The example below will load the specified image into gimp, flip it horizontally, save and exit gimp.
flip.py is the gimp plug-in and should be placed in your plug-ins directory which was ~/.gimp-2.6/plug-ins/flip.py in my case.
flip.py
from gimpfu import pdb, main, register, PF_STRING
from gimpenums import ORIENTATION_HORIZONTAL
def flip(file):
image = pdb.gimp_file_load(file, file)
drawable = pdb.gimp_image_get_active_layer(image)
pdb.gimp_image_flip(image, ORIENTATION_HORIZONTAL)
pdb.gimp_file_save(image, drawable, file, file)
pdb.gimp_image_delete(image)
args = [(PF_STRING, 'file', 'GlobPattern', '*.*')]
register('python-flip', '', '', '', '', '', '', '', args, [], flip)
main()
from the terminal one could run this:
gimp -i -b '(python-flip RUN-NONINTERACTIVE "/tmp/test.jpg")' -b '(gimp-quit 0)'
'''
from gimpfu import pdb, main, register, PF_STRING
from gimpenums import ORIENTATION_HORIZONTAL
def my_enfocar(file):
image = pdb.gimp_file_load(file, file)
drawable = pdb.gimp_image_get_active_layer(image)
pdb.plug_in_unsharp_mask(image, drawable, 5.0, 1.0, 0)
#pdb.gimp_image_flip(image, ORIENTATION_HORIZONTAL)
pdb.gimp_file_save(image, drawable, file, file)
pdb.gimp_image_delete(image)
args = [(PF_STRING, 'file', 'GlobPattern', '*.*')]
register('python-my-enfocar', '', '', '', '', '', '', '', args, [], my_enfocar)
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment