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

exiftool_resolution_calc()

Description

Extract and store dimensions, resolution, and unit (if available) from exif data
Exiftool output format (tab delimited): widthxheight resolution unit (e.g., 1440x1080 300 inches)

Parameters

ColumnTypeDefaultDescription
$file_path string Path to the original file.
$ref int Reference of the resource.
$remove_original boolean false Option to remove the original record. Used by update_resource_dimensions.php

Return

void

Location

include/metadata_functions.php lines 321 to 363

Definition

 
function exiftool_resolution_calc($file_path$ref$remove_original false)
{
    
$exiftool_fullpath get_utility_path("exiftool");
    
$command $exiftool_fullpath " -s -s -s -t -composite:imagesize -xresolution -resolutionunit ";
    
$command .= escapeshellarg($file_path);
    
$exif_output explode("\t"run_command($command));

    if (
count($exif_output) >= && $exif_output[0] != '') {
        if (
$remove_original) {
            
ps_query("DELETE FROM resource_dimensions WHERE resource= ?", ['i'$ref]);
        }
        
$wh explode("x"$exif_output[0]);
        if (
count($wh) > 1) {
            
$width $wh[0];
            
$height $wh[1];
            
$filesize filesize_unlimited($file_path);
            
$sql_insert "insert into resource_dimensions (resource,width,height,file_size";
            
$sql_params = [
                
's'$ref,
                
'i'$width,
                
'i'$height,
                
's'$filesize
            
];

            for (
$n 1$n count($exif_output); $n++) {
                
# Resolution may be omitted if not set; check values by type
                
if (is_int_loose($exif_output[$n])) {
                    
$sql_insert .= ",resolution";
                    
$sql_params[] = 'i';
                } else {
                    
$sql_insert .= ",unit";
                    
$sql_params[] = 's';
                }
                
$sql_params[] = $exif_output[$n];
            }

            
$sql_insert .= ")";
            
$sql_values "values (" ps_param_insert((count($sql_params) / 2)) . ")";
            
$sql $sql_insert $sql_values;
            
ps_query($sql$sql_params);
        }
    }
}

This article was last updated 15th June 2025 07:05 Europe/London time based on the source file dated 12th June 2025 10:10 Europe/London time.