summaryrefslogtreecommitdiff
path: root/scrape-codex.py
diff options
context:
space:
mode:
authorJules Laplace <julescarbon@gmail.com>2018-11-25 18:40:30 +0100
committerJules Laplace <julescarbon@gmail.com>2018-11-25 18:40:30 +0100
commit068961913177924dd01c4cfa49416babfcdd1251 (patch)
treef22e4b6461611953eea7c0548ba25bc59bdd05f7 /scrape-codex.py
parenta26acb22a08bed4ec3f163337e3a6714027deff3 (diff)
start/end
Diffstat (limited to 'scrape-codex.py')
-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__':