From 068961913177924dd01c4cfa49416babfcdd1251 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Sun, 25 Nov 2018 18:40:30 +0100 Subject: start/end --- scrape-codex.py | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) (limited to 'scrape-codex.py') diff --git a/scrape-codex.py b/scrape-codex.py index 619f452..b299df6 100644 --- a/scrape-codex.py +++ b/scrape-codex.py @@ -84,16 +84,32 @@ def grab(s, n): ww = 258 * (TILE_W - 1) hh = 258 * (TILE_H - 1) + start_w = 0 + end_w = 0 + start_h = 0 + end_h = 0 + fn = "./{}/{}/{}/{}_{}.jpg".format(TAG, ZOOM, page, 0, 0) image, width, height = load_image(fn) ww += width hh += height + start_w = width + start_h = height fn = "./{}/{}/{}/{}_{}.jpg".format(TAG, ZOOM, page, TILE_W, TILE_H) image, width, height = load_image(fn) ww += width hh += height + if image is None: + fn = "./{}/{}/{}/{}_{}.jpg".format(TAG, ZOOM, page, TILE_W-1, TILE_H) + image, width, height = load_image(fn) + ww += width + + fn = "./{}/{}/{}/{}_{}.jpg".format(TAG, ZOOM, page, TILE_W, TILE_H-1) + image, width, height = load_image(fn) + hh += height + # Build the new canvas by pasting the tiles across it canvas = Image.new('RGB', (ww, hh,)) x = 0 @@ -104,8 +120,14 @@ def grab(s, n): image, width, height = load_image(fn) if image: canvas.paste(image, (x, y)) - y += height - x += width + if j == 0: + y += start_h + else: + y += height + if i == 0: + x += start_w + else: + x += width canvas.save(out_fn) if __name__ == '__main__': -- cgit v1.2.3-70-g09d2