Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/ImageProcess.py
diff options
context:
space:
mode:
Diffstat (limited to 'ImageProcess.py')
-rw-r--r--ImageProcess.py61
1 files changed, 50 insertions, 11 deletions
diff --git a/ImageProcess.py b/ImageProcess.py
index 2e5cb54..26506a5 100644
--- a/ImageProcess.py
+++ b/ImageProcess.py
@@ -21,7 +21,7 @@ import gtk
from gtk import gdk
import gobject
import sys
-import Image,ImageEnhance,ImageFont,ImageFilter,ImageOps
+from PIL import Image,ImageEnhance,ImageFont,ImageFilter,ImageOps
import ImageDraw
import StringIO
import logging
@@ -47,6 +47,9 @@ class ImageProcessor(gtk.DrawingArea):
def __init__(self):
gtk.DrawingArea.__init__(self)
self.set_app_paintable(True)
+ self.undo = None
+ self.redo = None
+ self.save = None
self.pixbuf = None
self.zoom = None
self.input_text = "text to edit"
@@ -155,8 +158,7 @@ class ImageProcessor(gtk.DrawingArea):
if self.window:
alloc = self.get_allocation()
- rect = gdk.Rectangle(alloc.x, alloc.y,
- alloc.width, alloc.height)
+ rect = gdk.Rectangle(alloc.x, alloc.y,alloc.width, alloc.height)
self.window.invalidate_rect(rect, True)
self.window.process_updates(True)
@@ -214,28 +216,43 @@ class ImageProcessor(gtk.DrawingArea):
self._optimal_zoom_flag = True
if self.window:
im = self.pixbuftoImage(pixbuf)
+ self.undo=im.copy()
im.convert("RGB")
r, g, b = im.split()
im = Image.merge("RGB", (g,g,g))
+ self.redo=im.copy()
pix=self.imagetopixbuf(im)
self.set_pixbuf( pix )
self.window.process_updates( True )
- def image_copy(self,value):
- pixbuf = self.pixbuf
+ def image_undo(self):
self._image_changed_flag = True
self._optimal_zoom_flag = True
if self.window:
- im = self.pixbuftoImage(pixbuf)
- self.im = im.copy()
+ pix=self.imagetopixbuf(self.undo)
+ self.set_pixbuf( pix )
+ self.window.process_updates( True )
- def image_paste(self,value):
- pixbuf = self.pixbuf
+
+ def image_redo(self):
self._image_changed_flag = True
self._optimal_zoom_flag = True
if self.window:
- im = self.im
- pix=self.imagetopixbuf(im)
+ pix=self.imagetopixbuf(self.redo)
+ self.set_pixbuf( pix )
+ self.window.process_updates( True )
+ def image_save(self):
+ pixbuf=self.pixbuf
+ self._image_changed_flag = True
+ self._optimal_zoom_flag = True
+ if self.window:
+ pix=self.pixbuftoImage(pixbuf)
+ self.save=pix.copy()
+ def image_paste(self):
+ self._image_changed_flag = True
+ self._optimal_zoom_flag = True
+ if self.window:
+ pix=self.imagetopixbuf(self.save)
self.set_pixbuf( pix )
self.window.process_updates( True )
@@ -246,7 +263,9 @@ class ImageProcessor(gtk.DrawingArea):
self._optimal_zoom_flag = True
if self.window:
im = self.pixbuftoImage(pixbuf)
+ self.undo=im.copy()
im = im.filter(ImageFilter.BLUR)
+ self.redo=im.copy()
pix=self.imagetopixbuf(im)
self.set_pixbuf( pix )
self.window.process_updates( True )
@@ -258,7 +277,9 @@ class ImageProcessor(gtk.DrawingArea):
self._optimal_zoom_flag = True
if self.window:
im = self.pixbuftoImage(pixbuf)
+ self.undo=im.copy()
im = im.transpose(Image.FLIP_LEFT_RIGHT)
+ self.redo=im.copy()
pix=self.imagetopixbuf(im)
self.set_pixbuf( pix )
self.window.process_updates( True )
@@ -270,8 +291,10 @@ class ImageProcessor(gtk.DrawingArea):
self._optimal_zoom_flag = True
if self.window:
im = self.pixbuftoImage(pixbuf)
+ self.undo=im.copy()
w,h=im.size
im = im.offset(w/2,h/2)
+ self.redo=im.copy()
pix=self.imagetopixbuf(im)
self.set_pixbuf( pix )
self.window.process_updates( True )
@@ -283,7 +306,9 @@ class ImageProcessor(gtk.DrawingArea):
self._optimal_zoom_flag = True
if self.window:
im = self.pixbuftoImage(pixbuf)
+ self.undo=im.copy()
im = im.filter(ImageFilter.CONTOUR)
+ self.redo=im.copy()
pix=self.imagetopixbuf(im)
self.set_pixbuf( pix )
self.window.process_updates( True )
@@ -295,7 +320,9 @@ class ImageProcessor(gtk.DrawingArea):
self._optimal_zoom_flag = True
if self.window:
im = self.pixbuftoImage(pixbuf)
+ self.undo=im.copy()
im = im.filter(ImageFilter.FIND_EDGES)
+ self.redo=im.copy()
pix=self.imagetopixbuf(im)
self.set_pixbuf( pix )
self.window.process_updates( True )
@@ -307,7 +334,9 @@ class ImageProcessor(gtk.DrawingArea):
self._optimal_zoom_flag = True
if self.window:
im = self.pixbuftoImage(pixbuf)
+ self.undo=im.copy()
im = ImageOps.solarize(im, threshold=128)
+ self.redo=im.copy()
pix=self.imagetopixbuf(im)
self.set_pixbuf( pix )
self.window.process_updates( True )
@@ -336,7 +365,9 @@ class ImageProcessor(gtk.DrawingArea):
self.edit_text = edit_text
if self.window:
im = self.pixbuftoImage(pixbuf)
+ self.undo=im.copy()
out=self.Imprint(im, self.input_text,self.edit_text)
+ self.redo=out.copy()
pix=self.imagetopixbuf(out)
self.set_pixbuf( pix )
self.window.process_updates( True )
@@ -373,7 +404,9 @@ class ImageProcessor(gtk.DrawingArea):
self._optimal_zoom_flag = True
if self.window:
im = self.pixbuftoImage(pixbuf)
+ self.undo=im.copy()
im = im.filter(ImageFilter.SHARPEN)
+ self.redo=im.copy()
pix=self.imagetopixbuf(im)
self.set_pixbuf( pix )
self.window.process_updates( True )
@@ -385,7 +418,9 @@ class ImageProcessor(gtk.DrawingArea):
self._optimal_zoom_flag = True
if self.window:
im = self.pixbuftoImage(pixbuf)
+ self.undo=im.copy()
im = im.filter(ImageFilter.EMBOSS)
+ self.redo=im.copy()
pix=self.imagetopixbuf(im)
self.set_pixbuf( pix )
self.window.process_updates( True )
@@ -397,7 +432,9 @@ class ImageProcessor(gtk.DrawingArea):
self._optimal_zoom_flag = True
if self.window:
im = self.pixbuftoImage(pixbuf)
+ self.undo=im.copy()
im = ImageOps.invert(im)
+ self.redo=im.copy()
pix=self.imagetopixbuf(im)
self.set_pixbuf( pix )
self.window.process_updates( True )
@@ -412,6 +449,7 @@ class ImageProcessor(gtk.DrawingArea):
if self.window:
im1=Image.open(mark)
im = self.pixbuftoImage(pixbuf)
+ self.undo=im.copy()
if pos=="tile":
im = self.watermark(im, im1,"tile",0.5)
elif pos=="scale":
@@ -419,6 +457,7 @@ class ImageProcessor(gtk.DrawingArea):
else :#if pos is top_left
im = self.watermark(im, im1,(0,0),0.5)
#(raw_input('type of watermark(tile/scale,(xsize,ysize))')), 0.5)
+ self.redo=im.copy()
pix=self.imagetopixbuf(im)
self.set_pixbuf( pix )
self.window.process_updates( True )