NAME

IIIF::Request - IIIF Image API request object

SYNOPSIS

use IIIF::Request;

my $request = IIIF::Request->new('125,15,120,140/90,/!345/gray.jpg');

DESCRIPTION

Stores parts of an IIIF ImageAPI after {identifier}:

{region}/{size}/{rotation}/{quality}.{format}

In contrast to the IIIF Image API Specification, all parts are optional. Omitted parts are set to their default value, except for format which is allowed to be undefined. Parsing of percentage and degree values is more forgiving than required by the specification as values are normalized (e.g. removal of redundant digits). The following additional fields are set if deriveable form the request:

region_pct
region_px
upscale
size_pct
size_px
ratio
mirror
degree

METHODS

new( [ $request ] )

Parses a request string. It's ok to only include selected image manipulations. Will raise an error on invalid requests. The request is parsed independent from a specific image so regions and sizes outside of the image bound are not detected as invalid.

as_string

Returns the full request string. Percentage values and degrees are normalized.

is_default

Returns whether the request (without format) is the default request full/max/0/default to get an unmodified image.

canonical( $width, $height [, %max ] )

Returns the canonical request for an image of given width and height or undef if this would result in an invalid request (because region or size would be out of bounds). In contrast to the specification, the format is not required part of the canonical request.

Optional named arguments maxWidth and maxHeight in %max can be used to control maximum allowed image size. As specified, maxWidth is ignored unless maxHeight is also given. Option maxArea is not supported.

error

Raise an "Invalid IIIF Image API Request" error. Can also be used as function.