BUILD: remove the last of the imagemagick stuff

The only remaining thing depending on imagemagick are the dist scripts
This commit is contained in:
Nick Zatkovich 2017-07-30 23:26:52 -07:00
parent 6724ef5aba
commit 215b7c644e
13 changed files with 149 additions and 182 deletions

View file

@ -1,12 +1,10 @@
#/usr/bin/env python
# SPDX-License-Identifier: MIT
# Copyright (c) 2017 Martin Miller
# Copyright (c) 2017 Martin Miller, Nick Zatkovich
# https://stackoverflow.com/questions/12251896/colorize-image-while-preserving-transparency-with-pil
from PIL import Image
from ImageColor import getcolor, getrgb
from ImageOps import grayscale
from PIL import Image, ImageColor, ImageOps
def image_tint(image, tint=None):
if tint is None:
@ -14,8 +12,8 @@ def image_tint(image, tint=None):
if image.mode not in ['RGB', 'RGBA']:
image = image.convert('RGBA')
tr, tg, tb = getrgb(tint)
tl = getcolor(tint, "L") # tint color's overall luminosity
tr, tg, tb = ImageColor.getrgb(tint)
tl = ImageColor.getcolor(tint, "L") # tint color's overall luminosity
if not tl:
tl = 1 # avoid division by zero
tl = float(tl) # compute luminosity preserving tint factors
@ -27,7 +25,7 @@ def image_tint(image, tint=None):
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)))
l = grayscale(image) # 8-bit luminosity version of whole image
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
else: # include copy of image's alpha layer