This project has moved to https://github.com/lovasoa/dezoom.sh
Last active
December 7, 2016 09:22
-
-
Save lovasoa/8a176cb1c1079ba6447bb71b83135d8e to your computer and use it in GitHub Desktop.
Download and assemble tiles of an image
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
#!/bin/bash | |
width_in_tiles=$1 | |
height_in_tiles=$2 | |
url_template=$3 | |
export TMPDIR=$(mktemp -d) | |
filelist="" | |
for y in $(seq $height_in_tiles) | |
do | |
echo -ne "Downloading... $((100*$y/$height_in_tiles))% \r" | |
for x in $(seq $width_in_tiles) | |
do | |
url=$(echo $url_template | sed "s/%X/$x/" | sed "s/%Y/$y/") | |
outfile="$TMPDIR"/tile"$x"_"$y".jpg | |
wget -O "$outfile" "$url" 2>/dev/null & | |
filelist="$filelist $outfile" | |
done | |
wait | |
done | |
echo -e "\nTiles added." | |
i=0 | |
for f in $filelist | |
do | |
echo -ne "Assembling tiles: $((100*i/($width_in_tiles*$height_in_tiles)))% \r" > /dev/stderr | |
convert "$f" miff:- | |
let i=$i+1 | |
done | montage - -geometry +0+0 -tile "$width_in_tiles"x"$height_in_tiles" result.jpg | |
echo "Tiles successfully assembled in 'result.jpg'" | |
rm -rf "$TMPDIR" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment