summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--scrape-codex.py26
1 files changed, 24 insertions, 2 deletions
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__':