From 15f2e7ae8f6a164d018688bf2dfe357b96d30ed2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A1s=20Veres-Szentkir=C3=A1lyi?= Date: Sun, 3 Nov 2013 22:04:42 +0100 Subject: [PATCH] GIMP plugin skeleton (shows image in new window) --- pysstv/examples/gimp-plugin.py | 42 ++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100755 pysstv/examples/gimp-plugin.py diff --git a/pysstv/examples/gimp-plugin.py b/pysstv/examples/gimp-plugin.py new file mode 100755 index 0000000..ab0c757 --- /dev/null +++ b/pysstv/examples/gimp-plugin.py @@ -0,0 +1,42 @@ +#!/usr/bin/env python +# -*- encoding: utf-8 -*- + +# copy to ~/.gimp-2.8/plug-ins/ +# dependencies: GIMP 2.8, python-imaging-tk + +from gimpfu import register, main, pdb +from tempfile import mkstemp +from PIL import Image, ImageTk +from Tkinter import Tk, Label +import os + +def transmit_current_image(image, drawable): + handle, png_fn = mkstemp(suffix='.png', prefix='pysstv-gimp-') + os.fdopen(handle).close() + try: + pdb.gimp_file_save(image, drawable, png_fn, png_fn) + pil_img = Image.open(png_fn) + root = Tk() + tk_img = ImageTk.PhotoImage(pil_img) + img_widget = Label(root, image=tk_img) + img_widget.image = tk_img + img_widget.pack() + root.mainloop() + finally: + os.remove(png_fn) + +register( + "pysstv_for_gimp", + "PySSTV for GIMP", + "Transmits the current image using PySSTV", + "Andras Veres-Szentkiralyi", + "Andras Veres-Szentkiralyi", + "November 2013", + "/PySSTV/Transmit...", + "*", + [], + [], + transmit_current_image + ) + +main()