diff options
Diffstat (limited to 'crop-thirds.py')
| -rw-r--r-- | crop-thirds.py | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/crop-thirds.py b/crop-thirds.py index ee624bf..f0bcf18 100644 --- a/crop-thirds.py +++ b/crop-thirds.py @@ -52,10 +52,14 @@ if not opt.no_clobber: rmtree(out_path) for i in range(opt.count): - x = int(i / opt.count * dst_width) - x_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 + x_margin + x_margin) if x < 0: - x += src_width - crops.append((x, y0, x + crop_width + x_margin + x_margin, y0 + crop_height + y_margin + y_margin,)) + x = 0 + crops.append((x, y0, w, y0 + crop_height + margin + margin,)) path = os.path.join(out_path, chr(97 + i)) os.makedirs(path) paths.append(path) @@ -75,13 +79,15 @@ 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) - canvas.paste(image, (0, 0)) - canvas.paste(image, (src_width, 0)) for n, path in enumerate(paths): - canvas.crop(crops[n]).resize(dst_size).save(os.path.join(path, out_fn)) + image.crop(crops[n]).resize(dst_size).save(os.path.join(path, out_fn)) chunksize = 3 with Pool(processes=cpu_count()) as pool: |
