#!/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" OUTFILE=$2 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' ' '