Created
August 10, 2018 15:47
-
-
Save yoya/812fd814fa9c37cf2f369a67326a8c0f to your computer and use it in GitHub Desktop.
ImageOps any method call
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from PIL import Image, ImageOps | |
import sys | |
if len(sys.argv) < 4: | |
print ("Usage: python imageopt_test.py <grayscale|equalize|...> [<value>] <infile> <outfile>\n") | |
print (dir(ImageOps)) | |
exit (0); | |
method = sys.argv[1] | |
if len(sys.argv) == 4: | |
value = None | |
infile, outfile = sys.argv[2], sys.argv[3] | |
else: | |
value = float(sys.argv[2]) | |
infile, outfile = sys.argv[3], sys.argv[4] | |
im = Image.open(infile) | |
func = getattr(ImageOps, method); | |
if value is None: | |
im = func(im); | |
else: | |
im = func(im, value); | |
im.save(outfile) | |
im.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment