# 3 - Images and Text¶

https://labs.onb.ac.at/en/tool/sacha/

https://labs.onb.ac.at/en/dataset/akon/

https://labs.onb.ac.at/en/dataset/anno/

### In this block¶

- Overview IIIF
- Overview OCR formats

- Example: Create IIIF collection from SPARQL query result
- Example: Download pre-downsized images for machine learning
- Example: Download OCR text

## Overview IIIF¶

http://iiif.io/

### What is IIIF?¶

- International Image Interoperability Framework (http://iiif.io/ - well written, worth a read)
- Standardised method of describing and delivering images over the web
- Community that develops APIs and implements them in Software

Image courtesy of https://github.com/IIIF/training, CC-BY 4.0

### Why would I use this?¶

#### If you want to display images¶

- If you want to use one of several nice viewers for images (zoom, rotate, fullscreen ootb)
- If you want to include image data hosted elsewhere

#### If you want to process images¶

- If you want structured access to potentially huge sets of images
- If you want included metadata
- If you want to resize images before downloading

### How would I use this?¶

- You could access an image directly (Image API)
  - Parameters can be changed in the URL
  - https://iiif.onb.ac.at/images/AKON/AK035_199/199/full/full/0/native.jpg

- You could get a manifest JSON (Presentation API)
  - Contains images and metadata
  - https://iiif.onb.ac.at/presentation/AKON/AK035_199/manifest/

- You could get a collection JSON (Presentation API)
  - Contains manifests and possibly other collections
  - https://iiif.onb.ac.at/presentation/collection/pydays19

### Pics or didn't happen!¶

- The ONB Labs viewers use IIIF: https://labs.onb.ac.at/en/dataset/akon/

- Awesome IIIF-related resources : https://github.com/IIIF/awesome-iiif

- https://showcase.iiif.io/

- IIIF Presentation API
  - returns JSON-LD structured documents that together describe the structure and layout of a digitized object or other collection of images and related content
  - https://iiif.io/api/presentation/2.1/
  - https://iiif.onb.ac.at/presentation/ABO/+Z196807705/manifest/

- IIIF Image API
  - requesting and delivering images on the Web
  - https://iiif.io/api/image/2.1/
  - Image Request URI Syntax
    - {scheme}://{server}{/prefix}/{identifier}/{region}/{size}/{rotation}/{quality}.{format}
    - http://iiif.onb.ac.at/images/ABO/Z196807705/00000009/full/full/0/native.jpg
    - 90 degree rotation: http://iiif.onb.ac.at/images/ABO/Z196807705/00000009/full/full/90/native.jpg
    - "Articulus Quartus": https://iiif.onb.ac.at/images/ABO/Z196807705/00000009/pct:0,0,100,33/full/0/native.jpg

## Overview OCR formats¶

- ALTO (Analyzed Layout and Text Object)
  - OCR (Optical Character Recognition) data representation format
  - XML Schema
  - https://github.com/altoxml
  - https://www.loc.gov/standards/alto/

- 3 ALTO main elements
  - `<Description>`
    - metadata and general settings (e.g. measurement units) about the ALTO file
  - `<Styles>`
    - text and paragraph styles
  - `<Layout>`
    - content information
    - subdivided into `<Page>` elements

- hOCR
  - alternative to ALTO
  - based on XHTML
  - not used in the ONB Labs