Collections functions
General functions
Node functions
Render functions
Theme permission functions
User functions
Resource functions

iiif_get_image()

Description

Get the image for the specified identifier canvas and resource id


requires to return height & width back (e.g annotations don't require it).
Please note for the identifier - we use 'hpr' if the original file is not a JPG file it
will be the value of this metadata field for the given resource
Example:
$size_info = array(
'identifier' => 'hpr',
'return_height_width' => true
);

Parameters

ColumnTypeDefaultDescription
$identifier integer IIIF identifier (this associates resources via the metadata field set as $iiif_identifier_field
$resourceid integer Resource ID
$position string The canvas identifier, i.e position in the sequence. If $iiif_sequence_field is defined
$size_info array
$size array ResourceSpace size information. Required information: identifier and whether it

Return

array

Location

include/iiif_functions.php lines 1472 to 1520

Definition

 
function iiif_get_image($identifier,$resourceid,$position, array $size_info)
    {
    global 
$rooturl,$rootimageurl;

    
// Quick validation of the size_info param
    
if(empty($size_info) || (!isset($size_info['identifier']) && !isset($size_info['return_height_width'])))
        {
        return 
false;
        }

    
$size $size_info['identifier'];
    
$return_height_width $size_info['return_height_width'];

    
$img_path get_resource_path($resourceid,true,$size,false);
    if(!
file_exists($img_path))
        {
        return 
false;
        }

    
$image_size get_original_imagesize($resourceid$img_path);

    
$images = array();
    
$images["@context"] = "http://iiif.io/api/presentation/2/context.json";
    
$images["@id"] = $rooturl $identifier "/annotation/" $position;
    
$images["@type"] = "oa:Annotation";
    
$images["motivation"] = "sc:painting";

    
$images["resource"] = array();
    
$images["resource"]["@id"] = $rootimageurl $resourceid "/full/max/0/default.jpg";
    
$images["resource"]["@type"] = "dctypes:Image";
    
$images["resource"]["format"] = "image/jpeg";

    
$images["resource"]["height"] = intval($image_size[2]);
    
$images["resource"]["width"] = intval($image_size[1]);

    
$images["resource"]["service"] =array();
    
$images["resource"]["service"]["@context"] = "http://iiif.io/api/image/2/context.json";
    
$images["resource"]["service"]["@id"] = $rootimageurl $resourceid;
    
$images["resource"]["service"]["profile"] = "http://iiif.io/api/image/2/level1.json";
    
$images["on"] = $rooturl $identifier "/canvas/" $position;

    if(
$return_height_width)
        {
        
$images["height"] = intval($image_size[2]);
        
$images["width"] = intval($image_size[1]);
        }

    return 
$images;  
    }

This article was last updated 19th March 2024 10:05 Europe/London time based on the source file dated 8th March 2024 15:10 Europe/London time.