Advertisement
Guest User

Python GEGL Pygobject example

a guest
Nov 28th, 2013
291
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.89 KB | None | 0 0
  1. """
  2. Minimal Python snippet for usage of GEGL with Gobject Introspection
  3. - this inverts the colors of a PNG file.
  4.  
  5. Intended as bootstrap for building larger scripts.
  6.  
  7. License: Creative Commons - Atribution required. Author: João S. O. Bueno
  8. """
  9.  
  10. import sys
  11. from gi.repository import Gegl as gegl
  12.  
  13. try:
  14.     origin, target = sys.argv[1:3]
  15. except IndexError:
  16.     sys.stderr.write("Usage: %s origin_png target_png" % __file__)
  17.     sys.exit(1)
  18.  
  19. gegl.init([])
  20.  
  21. ops = gegl.list_operations()
  22.  
  23. x = gegl.Node()
  24.  
  25. y = gegl.Node()
  26. y.set_property("operation", "gegl:png-load")
  27. y.set_property("path", origin)
  28. x.add_child(y)
  29.  
  30. z = gegl.Node()
  31. z.set_property("operation", "gegl:invert")
  32. x.add_child(z)
  33.  
  34. w = gegl.Node()
  35. w.set_property("operation", "gegl:png-save")
  36. w.set_property("path", target)
  37. x.add_child(w)
  38.  
  39. y.connect_to("output",z,"input")
  40. z.connect_to("output", w, "input")
  41.  
  42. w.process()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement