Collections functions
Encryption functions
General functions
Theme permission functions
Resource functions

iiif_get_thumbnail()

Description

Get thumbnail information for the specified resource id ready for IIIF JSON encoding

Parameters

ColumnTypeDefaultDescription
$resourceid integer Resource ID

Return

array

Location

include/api_functions.php lines 231 to 265

Definition

 
function iiif_get_thumbnail($resourceid)
    {
    global 
$rootimageurl;
    
    
$img_path get_resource_path($resourceid,true,'thm',false);
    if(!
file_exists($img_path))
            {
            return 
false;
            }
            
    
$thumbnail = array();
    
$thumbnail["@id"] = $rootimageurl $resourceid "/full/thm/0/default.jpg";
    
$thumbnail["@type"] = "dctypes:Image";
    
     
// Get the size of the images
    
if ((list($tw,$th) = @getimagesize($img_path))!==false)
        {
        
$thumbnail["height"] = (int) $th;
        
$thumbnail["width"] = (int) $tw;   
        }
    else
        {
        
// Use defaults
        
$thumbnail["height"] = 150;
        
$thumbnail["width"] = 150;    
        }
            
    
$thumbnail["format"] = "image/jpeg";
    
    
$thumbnail["service"] =array();
    
$thumbnail["service"]["@context"] = "http://iiif.io/api/image/2/context.json";
    
$thumbnail["service"]["@id"] = $rootimageurl $resourceid;
    
$thumbnail["service"]["profile"] = "http://iiif.io/api/image/2/level1.json";
    return 
$thumbnail;
    }

This article was last updated 12th July 2020 04:05 Europe/London time based on the source file dated 25th June 2020 16:08 Europe/London time.