commit 73ca2bb2ac97de9bdce418935e2ed94a64403497 Author: Alexander Demidov Date: Wed Nov 20 17:24:18 2013 +0400 Initial commit diff --git a/.idea/.name b/.idea/.name new file mode 100644 index 0000000..0f89309 --- /dev/null +++ b/.idea/.name @@ -0,0 +1 @@ +PythonApi \ No newline at end of file diff --git a/.idea/PythonApi.iml b/.idea/PythonApi.iml new file mode 100644 index 0000000..cb7a849 --- /dev/null +++ b/.idea/PythonApi.iml @@ -0,0 +1,16 @@ + + + + + + + + + + + + + diff --git a/.idea/encodings.xml b/.idea/encodings.xml new file mode 100644 index 0000000..e206d70 --- /dev/null +++ b/.idea/encodings.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..cc5dc05 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..fbcfbc0 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/.idea/scopes/scope_settings.xml b/.idea/scopes/scope_settings.xml new file mode 100644 index 0000000..922003b --- /dev/null +++ b/.idea/scopes/scope_settings.xml @@ -0,0 +1,5 @@ + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..def6a6a --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/.idea/workspace.xml b/.idea/workspace.xml new file mode 100644 index 0000000..41a43ee --- /dev/null +++ b/.idea/workspace.xml @@ -0,0 +1,402 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1384940719357 + 1384940719357 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/resize.py b/resize.py new file mode 100755 index 0000000..48d22c2 --- /dev/null +++ b/resize.py @@ -0,0 +1,26 @@ +#!/usr/bin/env python +import os, sys +import Image +import ImageEnhance +import argparse +parser = argparse.ArgumentParser() +parser.add_argument("--width", dest="width", type=int, required=True) +parser.add_argument("--height", dest="height", type=int, required=True) +parser.add_argument("source", type=str) +parser.add_argument("destination", type=str) +args = parser.parse_args() + +size = args.width, args.height +infile = args.source +outfile = args.destination +try: + im = Image.open(infile) + im = im.convert() + im.thumbnail(size, Image.ANTIALIAS) + im_result = Image.new('RGB', (args.width, args.height), (255, 255, 255)) + im_result.paste(im, ((args.width - im.size[0]) / 2, (args.height - im.size[1]) / 2)) + enhancer = ImageEnhance.Contrast(im_result) + im_result = enhancer.enhance(1.05) + im_result.save(outfile, "JPEG", quality=100) +except IOError: + print("cannot create thumbnail for '%s'" % infile) diff --git a/square.py b/square.py new file mode 100755 index 0000000..9dec1f6 --- /dev/null +++ b/square.py @@ -0,0 +1,13 @@ +#!/usr/bin/env python +import argparse +parser = argparse.ArgumentParser() +parser.add_argument("square", type=int, + help="display a square of a given number") +parser.add_argument("-v", "--verbose", action="store_true", + help="increase output verbosity") +args = parser.parse_args() +answer = args.square**2 +if args.verbose: + print("the square of {} equals {}".format(args.square, answer)) +else: + print(answer) \ No newline at end of file