This commit is contained in:
Ethan Dalool 2017-06-04 11:10:28 -07:00
parent e66d2736f8
commit f66dbc331c
3 changed files with 30 additions and 16 deletions

View file

@ -22,7 +22,7 @@ def listfiles(directory):
files = [name for name in files if os.path.isfile(name)] files = [name for name in files if os.path.isfile(name)]
return files return files
def stitch(images, outputfilename): def stitch(images):
largest_width = max(image.size[0] for image in images) largest_width = max(image.size[0] for image in images)
largest_height = max(image.size[1] 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)) print('Using cell size of %dx%dpx' % (largest_width, largest_height))
@ -43,16 +43,18 @@ def stitch(images, outputfilename):
gridspot_y = index // grid_width gridspot_y = index // grid_width
pixel_x = (gridspot_x * largest_width) + pad_x pixel_x = (gridspot_x * largest_width) + pad_x
pixel_y = (gridspot_y * largest_height) + pad_y 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)) stitched_image.paste(image, (pixel_x, pixel_y))
print('Saving "%s"' % outputfilename) return stitched_image
stitched_image.save(outputfilename)
directory = sys.argv[1] if __name__ == '__main__':
images = listfiles(directory) directory = sys.argv[1]
directory_id = 'massstitch_%s.png' % directory images = listfiles(directory)
if directory_id in images: directory_id = 'massstitch_%s.png' % directory
images.remove(directory_id) if directory_id in images:
images = load_all_images(images) images.remove(directory_id)
stitch(images, directory_id) images = load_all_images(images)
stitched_image = stitch(images)
print('Saving "%s"' % directory_id)
stitched_image.save(directory_id)

View file

@ -11,8 +11,20 @@ import string
import sys import sys
import time 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:]) transformation = ' '.join(sys.argv[2:])
result = eval(transformation) if by_lines:
print(result) for line in text:
x = line
result = eval(transformation)
print(result)
else:
x = text
result = eval(transformation)
print(result)

View file

@ -1,7 +1,7 @@
import math import math
import random import random
import sys import sys
import bytestring from voussoirkit import bytestring
CHUNK_SIZE = 512 * (2 ** 10) CHUNK_SIZE = 512 * (2 ** 10)
def listget(li, index, fallback=None): def listget(li, index, fallback=None):
try: try:
@ -43,4 +43,4 @@ if filename is not None and filename.isdigit():
filename = None filename = None
for x in range(filecount): for x in range(filecount):
make_randomfile(bytes, filename) make_randomfile(bytes, filename)