def main(): if len(sys.argv)<1: print "Come on, give me some files to play with" return curves=None try: rgb=json.loads(open("adjustment.json", "r").read()) curves=rgb["red"]+rgb["blue"]+rgb["green"] print "Loaded curve adjustment layer" except: print "Some problem reading adjustment.json" pass print "Reading image " + sys.argv[1] img=Image.open(sys.argv[1]).convert("RGB") n=0 for f in sys.argv[1:]: new=Image.open(f).convert("RGB") if curves is not None: new=new.point(curves) n+=1 print "Read in image [%04d] [%s]" % (n,f) img=imageBlend(img, new, 1.0/n) del(new) img.convert("RGB").save("out.png") print "Written out.png"
def imageBlur(img, degree): if degree == 0.0: return img else: for i in range(int(degree)): img = img.filter(ImageFilter.BLUR) b = img b = b.filter(ImageFilter.BLUR) return imageBlend(img, b, float(degree - int(degree)))
def interp(s, other, r): "Interpolate r proportion of the way between this and another image" try: ret=imageBlend(s.image(), other.image(), r).convert("RGB") except ValueError: print "Eeeek! Failed to blend %s and %s" % (s.filename, other.filename) ret=None pass return ret
def imageBlur(img, degree): if degree==0.0: return img else: for i in range(int(degree)): img=img.filter(ImageFilter.BLUR) b=img b=b.filter(ImageFilter.BLUR) return imageBlend(img, b, float(degree-int(degree)))
def interp(self, other, r): "Interpolate r proportion of the way between this and another image" try: print "image %s" % self.image print "other %s" % other print "rem %s" % r ret = imageBlend(self.image, other.image, r).convert("RGB") except ValueError: print("Eeeek! Failed to blend %s and %s" % (self.filename, other.filename)) ret = None pass return ret
def interp(self, other, r): "Interpolate r proportion of the way between this and another image" try: print "image %s" % self.image print "other %s" % other print "rem %s" % r ret = imageBlend(self.image, other.image, r).convert("RGB") except ValueError: print ("Eeeek! Failed to blend %s and %s" % (self.filename, other.filename)) ret = None pass return ret
def imageAutoContrast(img, r=1.0): "Return a blend of image IMG with its auto-contrasted self" if r == 0.0: return img ac = ImageOps.autocontrast(img) return imageBlend(img, ac, r)
def imageAutoContrast(img, r=1.0): "Return a blend of image IMG with its auto-contrasted self" if r==0.0: return img ac=ImageOps.autocontrast(img) return imageBlend(img, ac, r)