User:Olpl/NationalGallery
Jump to navigation
Jump to search
A script to download high-resolution images of paintings in the National Gallery collection[1].
Prerequisites[edit]
- Bash
- ImageMagick (
sudo apt-get install imagemagick
)
Usage[edit]
zoom.sh <contentId>
E.g.
zoom.sh 6509
(Please don't upload this example image. It already exists at the Commons as Image:RokebyVenus.jpg.)
zoom.sh[edit]
#!/bin/bash if [ -z "$1" ] ; then echo "Usage: $0 contentId" >&2 ; exit 1 ; fi # maximum zoom level ZOOM="07" # strings they use to obfuscate TRFROM=0123456789 TRTO=vRfOdXapKz # estimated limits COLS=40 ROWS=40 # directory to store downloaded fragments CACHE=cache/$1 mkdir -pv $CACHE CONTENTID=$(printf "%05d" $1) WGET="wget -nv " for col in `seq -w 00 $COLS`; do for row in `seq -w 00 $ROWS`; do DEST="$CACHE/r$row-c$col.jpg" if [ ! -f "$DEST" ]; then #obfuscated tile ID TILE=$(echo "$row$CONTENTID$col$ZOOM" | tr $TRFROM $TRTO) $WGET -O $DEST "http://www.nationalgallery.org.uk/custom/ng/tile.php?id=$TILE" fi; if [ ! -s "$DEST" ]; then if [ "$col" -eq "00" ]; then ROWS=$(printf "%02d" $(( 10#$row - 1 ))) echo "New max ROWS = $ROWS"; break; else if [ "$row" -eq "00" ]; then echo "Final column is $col"; break 2; fi fi; fi; done; done; montage `find $CACHE -type f ! -size 0 | sort` -tile ${col}x -geometry +0+0 ${CONTENTID}.jpg ls -lh ${CONTENTID}.jpg
Alternatives[edit]
Alternatively, you can use Ruby-based natgal-dl from Paul Battley[2].