Library of Congress (LoC) image retrieval script.
The retriever.py
script retrieves a single volume of map images from the
Library of Congress. The script relies on retriever_config.yml
to provide
configuration values that "point" the script to the target image collection. The script is run from
the terminal and accepts a number of command line arguments:
-
Required: A
< key >
(str
) value that matches a map key in the companion< retriever_config.yml >
file. The< 'key' >
arg is used to filter the relevant map data contained in the loaded YAML file. -
Optional: A
< format >
(str
) value that sets the image extension. Options: 'jpg', 'gif', 'jp2', 'tif'. Default: 'jpg'. -
Optional: A
< size >
(int
) value that sets the width and height of the image scaled ton
percent of the width and height of the extracted region ('pct:n'). The aspect ratio of the returned image is the same as that of the extracted region. Default value =25
. -
Optional: A
< rotation >
(int
) value that sets the image rotation by degrees (0-360
). Default value =0
. -
Optional: A
< quality >
(str
) value that sets the image quality. Options: 'color', 'grey', 'bitonal', 'default'. Default value ='default'
. -
Optional: A
< output >
(str
) value corresponding to the filepath for local storage of the retrieved images. Default value ='./output'
.
Once configured, the script retrieves the target images, renames the downloaded files,
stores them locally in the < output >
location, and logs the process both via the terminal and
a log file.
{scheme}://{server}{/id_prefix}/{identifier}/{region}/{size}/{rotation}/{quality}.{format}
.jpg
(pct:25)
.gif
.jp2
.tif
(master)
For addtional information review the LoC's IIIF image retrieval API.
An example LoC Jupyter notebook is available that illustrates image retrieval techniques.