Coding standards
Security in ResourceSpace
Developer reference
Database
Action functions
Admin functions
Ajax functions
Annotation functions
API functions
Collections functions
Comment functions
Config functions
CSV export functions
Dash functions
Debug functions
Encryption functions
Facial recognition functions
File functions
General functions
Language functions
Log functions
Login functions
Message functions
Migration functions
Node functions
PDF functions
Plugin functions
Render functions
Reporting functions
Request functions
Research functions
Slideshow functions
Theme permission functions
User functions
Video functions
Database functions
Metadata functions
Resource functions
Search functions
Map functions
Job functions
Tab functions
Test 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 1516 to 1564

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 17th November 2024 15:05 Europe/London time based on the source file dated 28th May 2024 16:20 Europe/London time.