smon

smon

iiif_image_plug - An Elixir Plug implementing the IIIF image API specification.

The International Image Interoperability Framework describes itself:

IIIF is a set of open standards for delivering high-quality, attributed digital objects online at scale. It’s also an international community developing and implementing the IIIF APIs. IIIF is backed by a consortium of leading cultural institutions.

This plug implements the most basic of these standards: The image API (version 3). The official IIIF documentation does a good job of describing the API in detail, so here just a small example.

The basic API syntax is

{scheme}://{server}{/prefix}/{identifier}/{region}/{size}/{rotation}/{quality}.{format}

An example based on the plug’s sample image in development would be:

http://127.0.0.1:4000/bentheim.tif/full/max/0/default.jpg

Which would give me a jpg (see the format) version of the original tif:

Now I can change the region, size, rotation, quality and format parameters in my query. The following query will:

  • select a part of the image
    – left: 700 pixel
    – top: 500 pixel
    – width: 520 pixel
    – height: 520 pixel
  • scale the image to 89% of its original size
  • flip the image (!) and then rotate it by 53°
  • make the image bitonal
  • return the image as png
http://127.0.0.1:4000/bentheim.tif/700,500,520,520/pct:89/!53/bitonal.png

The result:

There exist several generic Javascript IIIF viewers that utilize this API to allow for optimized viewing (dynamic loading of parts of the image data based on zoom level/viewport).

WebGIS Javascript libraries like leaflet or OpenLayers support IIIF in one way or the other.

The image processing is handled by libvips via Vix.

See iiif_image_plug | Hex

Most Liked

smon

smon

As hinted in the last update, I rewrote the library utilizing the __using__ makro, which feels way better from a usability standpoint: Overview — IIIFImagePlug v0.6.0

Please poke at it and see if anything breaks or is missing. :wink:

smon

smon

The library is now at version 0.5.0, there is one major question I am still unsure about. Maybe somebody here has some insight:

I have currently defined callback functions as plug parameters to allow the library users’ to inject some of their logic. The primary example would be the identifier_to_path_callback, which allows the plug to construct a filesystem path for a given identifier.

Is this the best way to do it? It seems to me that callbacks are a black box for language servers, you will not get any feedback if your provided callback does implement arity, parameters or return values expected by the plug.

Is meta programming the way to go? The counter argument would be: The callbacks are currently quite simple, so meta programming could introduce quite some complexity on the plug’s code side that is not worth the trade off.

I am currently experimenting with the library while rewriting publication platform for archaeological excavations. This is still in an alpha, besides the IIIF stuff I am also experimenting with LiveView Hooks for OpenLayers, and other stuff - so this link might not work from time to time: https://publication.field.test.idai.world/projects/bourgou/2024-05-14/de/86787076-5253-4071-b1ad-b2644506974d

The platform itself is open source: GitHub

Where Next?

Popular in Libraries Top

OvermindDL1
Been making an MLElixir thing (not released yet…) for fun in spare time in the past day. I’m just trying to see how much I can get an ML...
132 13487 106
New
cjen07
parameterized pipe in elixir: |n> edit: negative index in |n> and mixed usage with |> are supported example: use ParamP...
New
pkrawat1
Presenting Aviacommerce, open source e-commerce platform in Elixir Aviacommerce is an open source e-commerce platform in Elixir. We at...
New
jakub-zawislak
Hi everyone, I’m coming from the Symfony (PHP) framework. I like Phoenix, but it has a one thing that was build much better in the Symfo...
New
Qqwy
Hello everyone, I wrote a small library today called MapDiff. It returns a map listing the (smallest amount of) changes to get from map...
New
woylie
Flop is an Elixir library that applies filtering, ordering and pagination parameters to your Ecto queries. offset-based pagination with...
New
alisinabh
Hey everyone i’ve developed a library for Jalaali calendar for elixir which supports converting Gregorian dates to Jalaali and vice vers...
New
ahamez
Hi everyone, I’ve been working on this protobuf library for 3 years. We use it in the company I work for, EasyMile, to communicate with ...
New
gabrielpoca
Hello everyone! I want to share with you something that I’m really proud of: https://stillstatic.io/ Still is a static site builder for...
New
KallDrexx
For a good number of months I've been working on creating a very basic RTMP live video streaming server. Now that I have a very, very ba...
New

Other popular topics Top

chrismccord
Phoenix 1.4.0 released Phoenix 1.4 is out! This release ships with exciting new features, most notably with HTTP2 support, improved deve...
688 30048 115
New
shahryarjb
Hello, I get Persian date from my client and convert it to normal calendar like this: def jalali_string_to_miladi_english_number(persi...
New
Harrisonl
We have an ECS cluster with 4 services, where each task joins a single cluster, via discovery ECS discovery service. Currently when I de...
New
Jim
As a follow up to my earlier question: I have the code compiling and running but not getting a successful login from the rest server. ...
New
fireproofsocks
I’m working on defining a simple Ecto schema for a table (in PostGres), but I don’t see where I can define a column as NOT NULL. Conside...
New
minhajuddin
I have seen a lot of code which picks the first element from a list using Enum.at(0) instead of List.first. Is there a reason why people ...
New
electic
Hi, I am new to Elixir. I am trying to use the DateTime component to insert a date into MySQL however the there seems to be no way to fo...
New
chrisalley
ExUnit now has describe blocks which is a welcome addition coming from RSpec. In the docs, it states that nested hierarchies of describe ...
New
josevalim
Hi everyone, One of the features added to Elixir early on to help integration with Erlang code was the idea of overridable function defi...
New
jay1
Why is it that the mnesia database isn’t the most preferred database for use in Elixir/Phoenix?
New

Sub Categories:

We're in Beta

About us Mission Statement