Skip to content

Instantly share code, notes, and snippets.

@yoya
Created August 10, 2018 15:47
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 yoya/812fd814fa9c37cf2f369a67326a8c0f to your computer and use it in GitHub Desktop.
Save yoya/812fd814fa9c37cf2f369a67326a8c0f to your computer and use it in GitHub Desktop.
ImageOps any method call
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