Last active
April 16, 2021 11:53
-
-
Save sakuro/2e9b91153fbca8d1e81b7e23559404e3 to your computer and use it in GitHub Desktop.
Concatenate images generated by mapshot (Factorio MOD)
This file contains 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
#!/bin/sh -ue | |
# mapshot-concat.sh map-xxxxxxxx/d-xxxxxxxx/zoom_x output.jpg | |
if [ -n "$WSL_DISTRO_NAME" ]; then | |
# WSL1/2 | |
FACTORIO_DIR="/mnt/c/Users/$USER/AppData/Roaming/Factorio" | |
elif [ "$(uname -o)" = Darwin ]; then | |
# macOS | |
FACTORIO_DIR="$HOME/Library/Application Support/Factorio" | |
else | |
# Linux | |
FACTORIO_DIR="$HOME/.factorio" | |
fi | |
MAPSHOT_DIR="$FACTORIO_DIR/script-output/mapshot" | |
find "$MAPSHOT_DIR/$1" -name '*.jpg' -print | | |
sed -e 's/tile_\(.*\)_\(.*\)\.jpg$/& \1 \2/' | | |
sort -k3n -k2n | | |
awk -v "outfile=$2" ' | |
NR == 1 { | |
xmin = $2 | |
ymin = $3 | |
} | |
{ | |
print "\047" $1 "\047" | |
} | |
END { | |
print outfile | |
xsize = $2 - xmin + 1 | |
ysize = $3 - ymin + 1 | |
print "gm montage -mode concatenate -tile", xsize "x" ysize | |
} | |
' | | |
sed -n -e '$!H' -e '${p;x;p}' | | |
tr '\012' ' ' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment