Skip to content

Instantly share code, notes, and snippets.

@beothorn
Created January 20, 2018 18:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save beothorn/77a2cfd1f27d4adb9eb813dd347a9bb0 to your computer and use it in GitHub Desktop.
Save beothorn/77a2cfd1f27d4adb9eb813dd347a9bb0 to your computer and use it in GitHub Desktop.
Enhances shadows from given image args: original destination brightness
from PIL import Image, ImageFilter, ImageChops, ImageEnhance
import sys
original_img = sys.argv[1]
dest_img = sys.argv[2]
mask_strength = sys.argv[3]
original = Image.open(original_img)
gray = original.convert("LA")
blurred = gray.filter(ImageFilter.GaussianBlur(radius=5))
blurred = blurred.convert("RGB")
enhancer = ImageEnhance.Brightness(blurred)
blurred = enhancer.enhance(float(mask_strength))
multiplied= ImageChops.multiply(original, blurred)
multiplied.save(dest_img)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment