Introduction

Historical maps and classical documents contain characters oriented in various directions. This tool uses polygon annotations to accurately mark up tilted characters, and leverages the tilt information to retrieve rotation-corrected images via the IIIF Image API.

How Tilt Calculation Works

Vertex Order Rules

When creating polygon annotations, specify vertices in the following order:

  1. Top-left -> 2. Bottom-left -> 3. Bottom-right -> 4. Top-right

By following this counter-clockwise order, the tilt angle can be uniquely calculated.

TBoopt-tloemf-tl(Ce1hf)atr(a2c)terareaTBoopt-troimg-hrti(g4h)t(3)

Please also refer to the following demo video.

https://youtu.be/P9srTeynXuk?si=mJO1yu3IhR0QFV-2

Angle Calculation Method

The tilt angle is calculated from the vector of the top edge (top-left -> top-right):

ccclioooefnnntEMVsssI(xetttIiitxrIiir1tddaFiia,exynffcyxgrRRt1==looo0etttvLttaaae(oo=tttrxtppiiit2oRRMoooi,piiannncy-ggte2lhhhp=<sett.aLf..ar-0ftxytaa)rx)amno3,--negim,2tliyVtt(eeiS3eoodr;fVrppyRGLtLL,(oeeectpxxffdlaa4ttxott,1..)cihyxyko4(;;wnbiZo(s+t1e=t8o0i3mVVs6-ee/0lrrp;ettMofeeastxxti)ht,33.i..PvVxyIee))r--;teVVxeerr2ttee(xxbo00t..txyom-right),Vertex3(top-right)

Practical Examples

Example 1: Horizontal Text, Nearly Level

Annotation data:

{}"]se{}{}l,e""""ctvtvtyayaoplplreueu""e"e::":"::[""F"S"rxv<aygsgwSvmhege=ln9ext0cmS3tle0onl,rse1"=c5,\t5"o9hr0t",t,1p2:3/1/,w2w4w4."w3.org/2000/svg\"><pathd=\"M9034.6115828.17L10261.0615835.12L10262.0815596.18L9030.3315590.72Z\"/svg>"

Calculation:

TTddaiooxynippgi--==lflreRei91ofg05=tth35a:t09at:.0ti(3.ao9(37nn092230-(=43--.09296.013113357°,348.,.241685511.,85125=7-894.0-=.1.4277.-8)222))837.4-591.0°

Result:

  • region: 9030,15590,1231,244
  • rotation: 91

Example 2: Diagonally Tilted Characters

Annotation data:

{}"]se{}{}l,e""""ctvtvtyayaoplplreueu""e"e::":"::[""F"S"rxv<aygsgwSvmhege=ln8ext8cmS4tle3onl,rse1"=c8,\t7"o7hr3t",t,3p2:0/,/3w6w5w".w3.org/2000/svg\"><pathd=\"M9064.9719139.05L9163.9818836.97L8944.3018773.62L8843.7319059.54Z\"/svg>"

Calculation:

TTddaiooxynippgi--==lflreRei81ofg89=tth40a:t35at:.9ti(7.ao9(35nn084268-(=44--.39719.01967769.0,3415°,.31199,917.190-30=52952.9-=10.2.552-2)4174).9)2.451-160.2°

Result:

  • region: 8843,18773,320,365
  • rotation: 160

Retrieving Images with the IIIF Image API

URL Structure

IIIF Image API URL structure:

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

Image Without Rotation

https://example.org/iiif/image/8843,18773,320,365/,200/0/default.png

Tilt-Corrected Image

https://example.org/iiif/image/8843,18773,320,365/,200/160/default.png

Retrieving with Transparent Background

To make the margins created by rotation transparent, use PNG format:

https://example.org/iiif/image/8843,18773,320,365/,200/160/default.png

Note: For JPEG format, margins are filled with white.

Rotation Feature Support Status

The rotation feature of the IIIF Image API is not supported by all image servers. The IIIF Image API defines the following Compliance Levels:

LevelRotation Feature
Level 0Only 0 degrees
Level 1Only 0 degrees
Level 20, 90, 180, 270 degrees (arbitrary angles are optional)

https://iiif.io/api/image/3.0/compliance/#33-rotation

https://iiif.io/api/image/2.1/compliance/#rotation

Many image servers operate at Level 1 or Level 2 and may not support arbitrary angle rotation. Support status can be checked in each image server’s info.json.

ccclioooefnnntEMVsssI(xetttIiitxrIiir1tddaFiia,exynffcyxgrRRt1==looo0etttvLttaaae(oo=tttrxtppiiit2oRRMoooi,piiannncy-ggte2lhhhp=<sett.aLf..ar-0ftxytaa)rx)amno3,--negim,2tliyVtt(eeiS3eoodr;fVrppyRGLtLL,(oeeectpxxffdlaa4ttxott,1..)cihyxyko4(;;wnbiZo(s+t1e=t8o0i3mVVs6-ee/0lrrp;ettMofeeastxxti)ht,33.i..PvVxyIee))r--;teVVxeerr2ttee(xxbo00t..txyom-right),Vertex3(top-right)

0

Only when rotationArbitrary is included is arbitrary angle rotation possible.

Display in IIIF Image Viewer

Even when the image server does not support rotation, you can view rotation-corrected images client-side using the IIIF Image Viewer. This viewer rotates images in the browser, so it does not depend on server-side rotation capabilities.

URL Parameters

ParameterDescriptionExample
iiifIIIF Image API info.json URLhttps://example.org/iiif/image/info.json
xywhCrop region (x,y,width,height)8843,18773,320,365
rotationRotation angle (degrees)160

Usage Example

Open sample image

Best Practices for Creating Annotations

1. Follow the Vertex Order

Always specify vertices in the order “top-left -> bottom-left -> bottom-right -> top-right.” If this order is broken, tilt calculation will not be performed correctly.

2. Be Aware of Character Orientation

Create annotations so that the reading direction of the characters (top edge) aligns with the “top-left -> top-right” line.

3. Include Some Margin

Including a slight margin rather than exactly fitting the character area improves readability.

Technical Background

Why Both FragmentSelector and SvgSelector Are Needed

  • FragmentSelector: Bounding box (xywh) for cropping images with the IIIF Image API
  • SvgSelector: Precise vertex coordinates for tilt calculation

With only FragmentSelector, tilt information is lost. With only SvgSelector, bounding box calculation is required. By keeping both, efficient processing is possible.

About IIIF Image API Rotation

The IIIF Image API rotation parameter:

  • Clockwise is positive
  • Range of 0 to 360
  • Decimal values are also accepted

The rotated image may be larger than the original rectangle. This is because the smallest axis-aligned rectangle that contains the rotated rectangle is returned.