Scrape an image from DeepZoom with R and magick, recomposing a single image from multiple tiles

Tags: #<Tag:0x00007fe4e1df3270> #<Tag:0x00007fe4e1df30e0> #<Tag:0x00007fe4e1df2f50> #<Tag:0x00007fe4e1df2d48>

rOpenSci package or resource used*


What did you do?

DeepZoom allows webmasters to display high resolution images in an online viewer. It mostly discourages downlading the original high resolution images to your local drive. Magick combined with rvest can be used to get these images nevertheless with the help of R.

Full code for doing so is presented on my blog on mapping and data mining

In the core of the code, I use the magick R package to recompose the whole image from the tiles. This in two embedded for-loops. The recomposing magic happens in the line

thisimageline <- image_append(c(thisimageline, newimage), stack=TRUE)

Where stack=TRUE means that you append image tiles vertically. This gives you a column of images of 1-image width. In the encompassing loop, you append columns horizonataly until you have the full width of the original image:

thisimage <- image_append(c(thisimage, thisimageline))