This repository contains a dockerized application to download images from IIIF servers, generate thumbnails for delivery on the web, and produce RDF files for loading up into the graph database for each image. Each RDF file contains info about the availability of the image from the IIIF server at the time that it was processed.
There are two containers:
- Image Processing API
- Image Queue Processor
This application is a FastAPI-based service for processing images. It downloads images from given URLs, generates thumbnails and other derivatives, and produces RDF data files with details about the images and their processing.
- Image Downloading: Downloads images from provided URLs.
- Thumbnail Generation: Creates thumbnails and other size variants of the images.
- RDF Data Generation: Produces RDF files with metadata about the images.
- Dockerized: The application is containerized with Docker for easy deployment.
- Logging: Detailed logging of the image processing steps.
/image-api/
│
├── image-processing-api/ # FastAPI application
│ ├── app/
│ │ ├── __init__.py
│ │ ├── main.py # Main application file
│ │ ├── routes/ # API route definitions
│ │ ├── models.py # Pydantic models
│ │ └── utils/ # Utility functions
│ ├── Dockerfile # Dockerfile for building the image
│ ├── requirements.txt # Python dependencies
│ └── tests/ # Test scripts
│
├── data/ # Data directory for RDF models
├── image-data/ # Directory for storing processed images
└── docker-compose.yml # Docker Compose configuration
- Docker
- Docker Compose
-
Clone the Repository
Clone this repository to your local machine or download the source code.
-
Navigate to the Project Directory
Change into the
image-api
directory:cd image-api
-
Environment Variables
Set the required environment variables. Create a
.env
file in theimage-api
directory with the following content:THUMBNAIL_BASE_URL=<your-thumbnail-base-url>
Replace
<your-thumbnail-base-url>
with the actual base URL for thumbnails. -
Build and Run with Docker Compose
From the
image-api
directory, run:docker-compose up --build
This command builds the Docker image and starts the container.
-
Accessing the API
The API will be available at
http://localhost:8005
. You can make requests to the API endpoints as defined in the application. -
Viewing Logs
To view the logs, use:
docker-compose logs -f
/process-image
: Accepts an image URL, downloads the image, generates thumbnails, and produces an RDF file./reverse-hash-image-URL/{hash}
: Given a hash, retrieves the original image URL.
To make changes to the application:
- Edit the files in the
image-processing-api
directory. - Rebuild the Docker container with
docker-compose up --build
.
(coming soon)
The aim of the image queue processor is to execute a SPARQL query to a specified SPARQL endpoint (taken from the sparql-endpoint.config file), save the response to a CSV file and then process those image URL's through the Image API endpoint. The Image processor will either retrieve images that have not yet been processed using the model "retrieve-unprocessed-images.ttl" or it will attempt to reprocess images that have returned an HTTP response that is not 200/3XX with the model "reprocess-invalid-images.ttl"