summaryrefslogtreecommitdiff
path: root/scrape-vam.py
diff options
context:
space:
mode:
authorJules Laplace <julescarbon@gmail.com>2018-11-26 22:47:47 +0100
committerJules Laplace <julescarbon@gmail.com>2018-11-26 22:47:47 +0100
commitade6db6766338104c9cf809d73c81908de67281e (patch)
tree4e4b512f234ee1916200d95b2e004a29153dd708 /scrape-vam.py
parent353b7de86f790a2ee03f2573218d15d51a855043 (diff)
fix edge
Diffstat (limited to 'scrape-vam.py')
-rw-r--r--scrape-vam.py24
1 files changed, 18 insertions, 6 deletions
diff --git a/scrape-vam.py b/scrape-vam.py
index 8ded1f6..f0a658c 100644
--- a/scrape-vam.py
+++ b/scrape-vam.py
@@ -31,10 +31,8 @@ def grab(page):
max_width = data['width']
max_height = data['height']
- TILE_W = round((max_width / ZOOM) / 256) + 1
- TILE_H = round((max_height / ZOOM) / 256) + 1
- if TILE_W < TILE_H:
- TILE_H += 1
+ TILE_W = round((max_width / ZOOM) / 256)
+ TILE_H = round((max_height / ZOOM) / 256)
print("{}x{}".format(TILE_W, TILE_H))
dataset = []
@@ -57,15 +55,29 @@ def grab(page):
# Build the new canvas by pasting the tiles across it
canvas = Image.new('RGB', (ww, hh,))
x = 0
- for i in range(0, TILE_W + 1):
+ for i in range(0, TILE_W):
y = 0
- for j in range(0, TILE_H + 1):
+ for j in range(0, TILE_H):
fn = "./{}/{}/{}/{}_{}.jpg".format(TAG, ZOOM, page, i, j)
image, width, height = load_image(fn)
if image:
+ if i == TILE_W-1:
+ width = max_width % 256
+ width += 1
+ else:
+ width = min(width, 256)
+ if j == TILE_H-1:
+ print(height)
+ height = max_height % 256
+ print(height)
+ # height += 1
+ else:
+ height = min(height, 256)
+ image.thumbnail((width, height,), Image.ANTIALIAS)
canvas.paste(image, (x, y))
y += 256
x += 256
+ print("{}x{} {}x{}".format(width, height, image.size[0], image.size[1]))
canvas.save(out_fn)
if __name__ == '__main__':