Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/Imaging/Scripts/enhancer.py
diff options
context:
space:
mode:
Diffstat (limited to 'Imaging/Scripts/enhancer.py')
-rw-r--r--Imaging/Scripts/enhancer.py53
1 files changed, 53 insertions, 0 deletions
diff --git a/Imaging/Scripts/enhancer.py b/Imaging/Scripts/enhancer.py
new file mode 100644
index 0000000..d581658
--- /dev/null
+++ b/Imaging/Scripts/enhancer.py
@@ -0,0 +1,53 @@
+#
+# The Python Imaging Library
+# $Id: enhancer.py 2134 2004-10-06 08:55:20Z fredrik $
+#
+# this demo script creates four windows containing an image and a slider.
+# drag the slider to modify the image.
+#
+
+from Tkinter import *
+import Image, ImageTk, ImageEnhance
+import sys
+
+#
+# enhancer widget
+
+class Enhance(Frame):
+ def __init__(self, master, image, name, enhancer, lo, hi):
+ Frame.__init__(self, master)
+
+ # set up the image
+ self.tkim = ImageTk.PhotoImage(image.mode, image.size)
+ self.enhancer = enhancer(image)
+ self.update("1.0") # normalize
+
+ # image window
+ Label(self, image=self.tkim).pack()
+
+ # scale
+ s = Scale(self, label=name, orient=HORIZONTAL,
+ from_=lo, to=hi, resolution=0.01,
+ command=self.update)
+ s.set(self.value)
+ s.pack()
+
+ def update(self, value):
+ self.value = eval(value)
+ self.tkim.paste(self.enhancer.enhance(self.value))
+
+#
+# main
+
+root = Tk()
+
+im = Image.open(sys.argv[1])
+
+im.thumbnail((200, 200))
+
+Enhance(root, im, "Color", ImageEnhance.Color, 0.0, 4.0).pack()
+Enhance(Toplevel(), im, "Sharpness", ImageEnhance.Sharpness, -2.0, 2.0).pack()
+Enhance(Toplevel(), im, "Brightness", ImageEnhance.Brightness, -1.0, 3.0).pack()
+Enhance(Toplevel(), im, "Contrast", ImageEnhance.Contrast, -1.0, 3.0).pack()
+
+root.mainloop()