• I want to combine the map tiles generated by dynmap in Micra into one image. So far I have been opening the dynmap screen and taking screenshots, but I want to use cron to automatically date and save the screenshots, so I write a script.

image python

import numpy as np
import skimage.util
import skimage.io

images = []
for x in reversed(range(32)):
    for y in range(32):
        image = skimage.io.imread(f'/opt/minecraft_server/plugins/dynmap/web/tiles/world/t/0_0/{y}_{x}.jpg/')
        images.append(image)

out = skimage.util.montage(images, grid_shape=(32, 32), multichannel=True)
skimage.io.imsave('out.jpg', out)

It’s done.

Create different places image py

import numpy as np
import skimage.util
import skimage.io

TILE_DIR = "/opt/minecraft_server/plugins/dynmap/web/tiles"
world = "world"
cx = 0
cy = 1

images = []
for x in reversed(range(32)):
    for y in range(32):
        gx = cx * 32 + x
        gy = cy * 32 + y
        image = skimage.io.imread(f'{TILE_DIR}/{world}/t/{cy}_{cx}/{gy}_{gx}.jpg/')
        images.append(image)

out = skimage.util.montage(images, grid_shape=(32, 32), multichannel=True)
skimage.io.imsave('out.jpg', out)

I thought it was a chunk and named it cx, but that doesn’t seem to be the case, because a chunk is 16 units.

The tiles are joined, not manually screenshot, so they connect perfectly when lined up.

  • (They are lined up when viewed on a PC, on a smartphone they appear to be line-breaking due to lack of width.) imageimage

Then we’ll make sure to save this with a date and time and start it in cron. py

#!/home/nishio/venv/bin/python

import numpy as np
import skimage.util
import skimage.io
import time
# settings
TILE_DIR = "/opt/minecraft_server/plugins/dynmap/web/tiles"
OUT_DIR = "/home/nishio/dynmap_concat"
world = "world"
tx = 0
ty = 1
targets = [[0, 0], [0, 1]]
# end settings
today = time.strftime("%Y-%m-%d")

for [tx, ty] in targets:
    images = []
    for x in reversed(range(32)):
        for y in range(32):
            gx = tx * 32 + x
            gy = ty * 32 + y
            image = skimage.io.imread(f'{TILE_DIR}/{world}/t/{ty}_{tx}/{gy}_{gx}.jpg/')
            images.append(image)
    out = skimage.util.montage(images, grid_shape=(32, 32), multichannel=True)
    skimage.io.imsave(f'{OUT_DIR}/{tx}_{ty}_{today}.jpg', out)

TODO When I have accumulated a certain amount, I’ll connect them to make a time-lapse video.


This page is auto-translated from /nishio/dynmapのタイルを繋ぎ合わせて大きな画像をつくる using DeepL. If you looks something interesting but the auto-translated English is not good enough to understand it, feel free to let me know at @nishio_en. I’m very happy to spread my thought to non-Japanese readers.