Ejemplo n.º 1
0
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")
Ejemplo n.º 2
0
def interpolateImage(task, outdir):
    "implement task - interpolate between two images"
    f1, f2, alpha, counter = task
    tlog("Image %d: files=[%s],[%s] prop=%f" % (counter, f1, f2, alpha))
    img1 = Image.open(f1).convert("RGB")
    img2 = Image.open(f2).convert("RGB")
    img = imageBlend(img1, img2, alpha).convert("RGB")
    outfname = outdir + "/img-%05d.jpg" % (counter)
    img.save(outfname)
Ejemplo n.º 3
0
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)))
Ejemplo n.º 4
0
 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
Ejemplo n.º 5
0
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)