diff options
Diffstat (limited to 'crop-thirds.py')
| -rw-r--r-- | crop-thirds.py | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/crop-thirds.py b/crop-thirds.py index 34f2336..c189b74 100644 --- a/crop-thirds.py +++ b/crop-thirds.py @@ -22,7 +22,7 @@ parser.add_argument('--vertical_offset', type=int, default=512) # parser.add_argument('--dst_height', type=int, default=512) parser.add_argument('--count', type=int, default=3) parser.add_argument('--aspect', type=float, default=3.0) -parser.add_argument('--folder_id', type=int, required=True) +# parser.add_argument('--folder_id', type=int, required=True) parser.add_argument('--overlap', type=float, default=0.5) parser.add_argument('--clobber', action='store_false') opt = parser.parse_args() @@ -35,14 +35,14 @@ dst_height = int(dst_width / opt.aspect) dst_size = (dst_width, dst_height,) offsets = [] +letters = [] -for i in range(count): - offsets.append(int(i / count * dst_width)) +for i in range(opt.count): + offsets.append(int(i / opt.count * dst_width)) + letters.append(chr(97 + i)) y0 = opt.vertical_offset - dst_height / 2 - -crops = [(x, y0, x + dst_width, d0 + dst_height,) for x in offsets] -letters = ['a', 'b', 'c'] +crops = [(x, y0, x + dst_width, y0 + dst_height,) for x in offsets] labels = [opt.label + '_' + letter for letter in letters] paths = [os.path.join(opt.out_dir, label) for label in labels] @@ -64,13 +64,11 @@ def build_thumbnail(i, fn): if (i % 100) == 0: print("{}...".format(i)) - canvas = Image.new('RGB', (int(src_width * 3/2), src_height,)) + canvas = Image.new('RGB', (int(src_width), src_height,)) 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]).save(os.path.join(path, out_fn)) + image.crop(crops[n]).save(os.path.join(path, out_fn)) chunksize = 3 with Pool(processes=cpu_count()) as pool: |
