diff options
| -rwxr-xr-x | .gitignore | 1 | ||||
| -rw-r--r-- | crop-thirds.py | 19 |
2 files changed, 14 insertions, 6 deletions
@@ -49,4 +49,5 @@ results sequences checkpoints datasets +thirds diff --git a/crop-thirds.py b/crop-thirds.py index 12e3dc3..f0bcf18 100644 --- a/crop-thirds.py +++ b/crop-thirds.py @@ -20,7 +20,7 @@ parser.add_argument('--vertical_offset', type=int, default=256) # parser.add_argument('--dst_height', type=int, default=512) parser.add_argument('--count', type=int, default=3) parser.add_argument('--max', type=int, default=99997) -parser.add_argument('--crop_aspect' type=float, default=1.5) +parser.add_argument('--crop_aspect', type=float, default=1.5) parser.add_argument('--aspect', type=float, default=3.0) # parser.add_argument('--folder_id', type=int, required=True) parser.add_argument('--margin', type=int, default=16) @@ -36,9 +36,12 @@ dst_height = int(dst_width / opt.aspect) crop_width = dst_width crop_height = int(dst_width / opt.aspect * opt.crop_aspect) +x_margin = opt.margin +y_margin = opt.margin * opt.crop_aspect + crop_size = (crop_width, crop_height,) -dst_size = (dst_width, dst_height,) -y0 = opt.vertical_offset - crop_height / 2 - margin +dst_size = (dst_width + opt.margin * 2, dst_height + opt.margin * 2,) +y0 = opt.vertical_offset - crop_height / 2 - y_margin crops = [] paths = [] @@ -49,11 +52,11 @@ if not opt.no_clobber: rmtree(out_path) for i in range(opt.count): - x = int(i / opt.count * src_width) - margin - w = x + crop_width + margin + margin + x = int(i / opt.count * src_width) - x_margin + w = x + crop_width + x_margin + x_margin if w > src_width: w = src_width - x = src_width - (crop_width + margin + margin) + x = src_width - (crop_width + x_margin + x_margin) if x < 0: x = 0 crops.append((x, y0, w, y0 + crop_height + margin + margin,)) @@ -76,7 +79,11 @@ def build_thumbnail(i, fn): if (i % 100) == 0: print("{}...".format(i)) +<<<<<<< HEAD + canvas = Image.new('RGB', (int(src_width + dst_width + x_margin), src_height,)) +======= # canvas = Image.new('RGB', (int(src_width + dst_width + margin), src_height,)) +>>>>>>> 455c3fef555b6f556321c2db6a8dc355154666da image = Image.open(fn) for n, path in enumerate(paths): |
