From f66dbc331c76bb0a0c2a883302aecf2bf65154ce Mon Sep 17 00:00:00 2001 From: Ethan Dalool Date: Sun, 4 Jun 2017 11:10:28 -0700 Subject: [PATCH] else --- MassStitching/massstitch.py | 24 +++++++++++++----------- Toolbox/eval.py | 18 +++++++++++++++--- Toolbox/randomfile.py | 4 ++-- 3 files changed, 30 insertions(+), 16 deletions(-) diff --git a/MassStitching/massstitch.py b/MassStitching/massstitch.py index 9ecb219..4b1a057 100644 --- a/MassStitching/massstitch.py +++ b/MassStitching/massstitch.py @@ -22,7 +22,7 @@ def listfiles(directory): files = [name for name in files if os.path.isfile(name)] return files -def stitch(images, outputfilename): +def stitch(images): largest_width = max(image.size[0] for image in images) largest_height = max(image.size[1] for image in images) print('Using cell size of %dx%dpx' % (largest_width, largest_height)) @@ -43,16 +43,18 @@ def stitch(images, outputfilename): gridspot_y = index // grid_width pixel_x = (gridspot_x * largest_width) + pad_x pixel_y = (gridspot_y * largest_height) + pad_y - print(index, image.filename, gridspot_x, gridspot_y, pixel_x, pixel_y) + print(index, gridspot_x, gridspot_y, pixel_x, pixel_y) stitched_image.paste(image, (pixel_x, pixel_y)) - print('Saving "%s"' % outputfilename) - stitched_image.save(outputfilename) + return stitched_image -directory = sys.argv[1] -images = listfiles(directory) -directory_id = 'massstitch_%s.png' % directory -if directory_id in images: - images.remove(directory_id) -images = load_all_images(images) -stitch(images, directory_id) \ No newline at end of file +if __name__ == '__main__': + directory = sys.argv[1] + images = listfiles(directory) + directory_id = 'massstitch_%s.png' % directory + if directory_id in images: + images.remove(directory_id) + images = load_all_images(images) + stitched_image = stitch(images) + print('Saving "%s"' % directory_id) + stitched_image.save(directory_id) \ No newline at end of file diff --git a/Toolbox/eval.py b/Toolbox/eval.py index 8e04c17..5968abb 100644 --- a/Toolbox/eval.py +++ b/Toolbox/eval.py @@ -11,8 +11,20 @@ import string import sys import time -x = clipext.resolve(sys.argv[1]) +if '--lines' in sys.argv: + by_lines = True + sys.argv.remove('--lines') +else: + by_lines = False +text = clipext.resolve(sys.argv[1], split_lines=by_lines) transformation = ' '.join(sys.argv[2:]) -result = eval(transformation) -print(result) +if by_lines: + for line in text: + x = line + result = eval(transformation) + print(result) +else: + x = text + result = eval(transformation) + print(result) diff --git a/Toolbox/randomfile.py b/Toolbox/randomfile.py index 33c5295..c9f473b 100644 --- a/Toolbox/randomfile.py +++ b/Toolbox/randomfile.py @@ -1,7 +1,7 @@ import math import random import sys -import bytestring +from voussoirkit import bytestring CHUNK_SIZE = 512 * (2 ** 10) def listget(li, index, fallback=None): try: @@ -43,4 +43,4 @@ if filename is not None and filename.isdigit(): filename = None for x in range(filecount): - make_randomfile(bytes, filename) \ No newline at end of file + make_randomfile(bytes, filename)