From e9015b43b36f39379a1b28bd415846c7dc216c15 Mon Sep 17 00:00:00 2001 From: Nick Zatkovich Date: Mon, 31 Jul 2017 11:31:02 -0700 Subject: [PATCH] python3 compatibility fixes --- graphics/text/create_caption.py | 10 +++++----- graphics/text/tint.py | 8 ++++---- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/graphics/text/create_caption.py b/graphics/text/create_caption.py index 20b62387..bb687fa0 100644 --- a/graphics/text/create_caption.py +++ b/graphics/text/create_caption.py @@ -21,17 +21,17 @@ image = Image.new("RGBA", background_image.size, (0, 0, 0, 0)) draw = ImageDraw.Draw(image) txt1_size = draw.textsize(txt1, font=font) txt2_size = draw.textsize(txt2, font=font) -draw.text((5, (image.height - txt1_size[1] - 5)), txt1, font=font, fill=(255,165,0,255)) -draw.text(((image.width - txt2_size[0] - 10), (image.height - txt2_size[1] - 5)), txt2, font=font, fill=(255,165,0,255)) +draw.text((5, int(image.height - txt1_size[1] - 5)), txt1, font=font, fill=(255,165,0,255)) +draw.text((int(image.width - txt2_size[0] - 10), int(image.height - txt2_size[1] - 5)), txt2, font=font, fill=(255,165,0,255)) if len(sys.argv) > 3: #paste the other stuff onto the thing. logo = Image.open(sys.argv[2]) logo.load() phase = Image.open(sys.argv[3]) - phase.load() - image.paste(logo, ((image.width/2 - logo.width/2), 18)) - image.paste(phase, ((image.width/2 - phase.width/2), (image.height - logo.height - 10))) + phase.load + image.paste(logo, ((int(image.width/2) - int(logo.width/2), 18))) + image.paste(phase, ((int(image.width/2) - int(phase.width/2)), int(image.height - phase.height - 30))) outfile_name = sys.argv[4] else: outfile_name = sys.argv[2] diff --git a/graphics/text/tint.py b/graphics/text/tint.py index 31c7ece4..a766b674 100644 --- a/graphics/text/tint.py +++ b/graphics/text/tint.py @@ -22,9 +22,9 @@ def image_tint(image, tint=None): # create look-up tables to map luminosity to adjusted tint # (using floating-point math only to compute table) - luts = (map(lambda lr: int(lr * sr + 0.5), range(256)) + - map(lambda lg: int(lg * sg + 0.5), range(256)) + - map(lambda lb: int(lb * sb + 0.5), range(256))) + luts = (tuple(map(lambda lr: int(lr * sr + 0.5), range(256))) + + tuple(map(lambda lg: int(lg * sg + 0.5), range(256))) + + tuple(map(lambda lb: int(lb * sb + 0.5), range(256)))) l = ImageOps.grayscale(image) # 8-bit luminosity version of whole image if Image.getmodebands(image.mode) < 4: merge_args = (image.mode, (l, l, l)) # for RGB verion of grayscale @@ -32,7 +32,7 @@ def image_tint(image, tint=None): a = Image.new("L", image.size) a.putdata(image.getdata(3)) merge_args = (image.mode, (l, l, l, a)) # for RGBA verion of grayscale - luts += range(256) # for 1:1 mapping of copied alpha values + luts += tuple(range(256)) # for 1:1 mapping of copied alpha values return Image.merge(*merge_args).point(luts)