Created
April 7, 2020 08:08
-
-
Save tkon99/1151dab718b06727a61508827fd62c78 to your computer and use it in GitHub Desktop.
RDR2 Map Tile Creator
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import glob | |
import math | |
import numpy | |
from pathlib import Path | |
from PIL import Image | |
Image.MAX_IMAGE_PIXELS = 933120000 | |
zoomdir = "C:/Users/tkon9/Desktop/RDR2MapStream/content/maps/sat" # Essentially the output directory | |
highX = 95 | |
highY = 75 | |
res = 256 | |
highresImg = Image.open(zoomdir+"/testmerged_sat.jpg") # Big picture to tile | |
# For all levels 7 to 1 | |
for z in range(1,8)[::-1]: | |
Path(zoomdir+"/out/"+str(z)+"/").mkdir(parents=True, exist_ok=True) | |
print("Level:",z) | |
ys = math.ceil(highY/(2**(7-z))) | |
xs = math.ceil(highX/(2**(7-z))) | |
internalres = res*(2**(7-z)) | |
for y in range(0,ys): | |
for x in range(0,xs): | |
print("Doing: Z:",z,"X:",x,"Y:",y) | |
x1 = x*internalres | |
y1 = y*internalres | |
x2 = (x+1)*internalres | |
y2 = (y+1)*internalres | |
tile = Image.new('RGB', (x2 - x1, y2 - y1), (210, 183, 144)) # RDR background color | |
tile.paste(highresImg, (-x1, -y1)) | |
tile = tile.resize((res,res)) | |
tile.save(zoomdir+"/out/"+str(z)+"/"+str(x)+"_"+str(y)+".jpg") | |
print("Done!") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment