def apply_effects(image, effects):
"""method to apply effects to original image from list of effects
"""
for effect in effects:
gray = ImageOps.grayscale(image)
# dictionary with all the availble effects
all_effects = {
'BLUR': image.filter(ImageFilter.BLUR),
'CONTOUR': image.filter(ImageFilter.CONTOUR),
'EMBOSS': image.filter(ImageFilter.EMBOSS),
'SMOOTH': image.filter(ImageFilter.SMOOTH),
'HULK': ImageOps.colorize(gray, (0, 0, 0, 0), '#00ff00'),
'FLIP': ImageOps.flip(image),
'MIRROR': ImageOps.mirror(image),
'INVERT': ImageOps.invert(image),
'SOLARIZE': ImageOps.solarize(image),
'GREYSCALE': ImageOps.grayscale(image),
}
phedited = all_effects[effect]
image = phedited
return phedited
评论列表
文章目录