Liberating culture
The National Gallery houses the national collection of Western European painting from the 13th to the 19th centuries. It is on show 361 days a year, free of charge.
You can look at the collection online via a fancy zooming panning scrolling widget. It’s very clever, but the experience of peering at a painting through a tiny porthole (even on the ‘full screen’ version) isn’t the best one.
I don’t believe that our shared cultural heritage should be locked up behind browser widgets, so I took a look at reverse-engineering the system. That may sound controversial, but it’s actually completely in line with the Gallery’s stated aim of making its pictures available:
The Gallery aims to study and care for the collection, while encouraging the widest possible access to the pictures
Whether they actually believe their rhetoric, I don’t know. We’ll see!
Each painting is cut up into tiles at various resolutions to support panning and zooming. There’s a cursory effort at obfuscating the tile identifiers, via a little obfuscate function that turns the digits 0123456789 into vRfOdXapKz respectively and by mixing the parameters together in a strange order. But really, it’s fairly simple stuff. Knowing the size of the image, the size of a tile, and the zoom level, it’s trivial to fetch all the tiles.
Having got a set of tiles, stitching them together is a little harder. The full image can be very large (5,000 pixels on a side), and naïvely-written image processing libraries tend to use up all the available memory.
The solution I found that worked best was the montage command from ImageMagick. However, since it’s designed to work with tiles that are all the same shape, I had to do a bit of preprocessing on the truncated tiles at the right-hand and bottom edges to make them square beforehand, then crop the resultant image down to the desired size.
Having done all that, though, I can now pull down all the tiles and stitch them into a single beautiful image. I can now have high-quality offline copies of works of art to browse at my leisure, use as a desktop background, set as a screensaver, or just draw moustaches on.
The fact that you can now get these high-quality images does not, unfortunately, mean that you can do what you like with them. It may sound crazy, but, at least in the UK, copyright does apply to the photos, even though they may simply be reproductions of works made hundreds of years ago.
I’ve put my code on GitHub along with instructions. Some computing knowledge is required to use it, and it almost certainly won’t work on Windows in its current state.
2009-06-27 18:48 UTC. Comments: 5.

tino
Wrote at 2009-07-06 12:09 UTC using Firefox 3.0.11 on Windows XP:
Great site to feature, Paul.You must get this kind of request all the time, but if you don’t ask, you don’t get, so…
...it would be great if you could rustle up a .exe version of this for us Windows simpletons. Sorry *_*
Actually, I wish all galleries did this with their permanent collections. I’m very glad the National is leading the way by taking the online audience so seriously.
You just never have the time to go round a gallery looking at every work in the collection in real detail.
Plus, even if you did get to know every last one on display, every time new works were bought or resurrected from the cellars, you wouldn’t want to go all the way back there for just one or two more, would you?
tino
Tim
Wrote at 2009-07-07 20:30 UTC using Firefox 3.0.11 on Linux:
I seem to be able to get the “full screen” version to take up nearly all of my 22” wide screen and use a variety of zoom levels which is pretty much all I’d want to do with a locally saved copy.I can appreciate the urge to take the viewer apart and see how it works, but in fairness I don’t have enough hard drive for all the works of art in the world, so if galleries want to provide them online like this for me to access anywhere I think it’s great, and I’m happy to leave them there.
This contrasts with the iPlayer content, which I like to have on my phone to fill the odd half hour, but I’m not about to put up with high prices for low speeds (and sometimes no mobile interweb connection at all).
Paul Battley
Wrote at 2009-07-07 22:24 UTC using Mozilla 1.9.1.1pre on Linux:
If all you want to do is look at the picture online, then I accept that there’s probably no benefit to this program, although on my somewhat less than 22” laptop, only about 3/4 of the screen is actually image even with the full screen viewer.This program is for all the other things you might want to do with a picture. Print it. Set it as your desktop wallpaper. Analyse it. See if you can perform an anamorphic transform on the skull in Holbein’s Ambassadors. Make a tasteless parody of the Supper at Emmaus. Do something I haven’t thought of. More importantly, do something the National Gallery hasn’t thought of.
Ed
Wrote at 2009-07-18 00:02 UTC using Firefox 3.5 on Mac OS X:
Lucky it wasn’t you who put these images on Wikipedia – or, being in the UK, you’d have a much harder time defending yourself. It seems the National Gallery aren’t too keen on people using their images.I can understand their point – for personal use, I see no reason to make an issue of it – commercially though, they do currently make a reasonable income from images – which is their legal right, as the law stands now. Placing the images on wikipedia/wikimedia commons clearly jeopardises that. Digitising these images is certainly not free – I’ve no idea how they do it, but it must be relatively expensive. I can understand them expecting to have some control over their use, or at least usage rights.
Any thoughts on this?
Paul Battley
Wrote at 2009-07-18 00:17 UTC using Mozilla 1.9.1.1pre on Linux:
Ed, you’ve confused the National Gallery and the National Portrait Gallery. That aside, though, it’s definitely the case that someone could use this code to upload all the images to Wikimedia if they were so inclined. Given that it only took me a couple of hours to write this, obtaining the images is not a high barrier.However, when you say that it’s ‘lucky’ that it wasn’t I who put the images on Wikimedia, you miss the point. Luck isn’t involved. I may choose to download these paintings, but to upload them would be a different matter entirely. I choose not to go there.
I would love for these images to be available to anyone, but—at least in England, where I live—the law does not allow that. I’m only making personal use of these pictures.