📄 canon.php
字号:
<?php
/******************************************************************************
*
* Filename: canon.php
*
* Description: Canon Makernote Parser
* Provides functions to decode an Canon EXIF makernote and to interpret
* the resulting array into html.
*
* Canon Makernote Format:
*
* Field Size Description
* ----------------------------------------------------------------
* IFD Data Variable Standard IFD Data using Canon Tags
* ----------------------------------------------------------------
*
*
* Author: Evan Hunter
*
* Date: 30/7/2004
*
* Project: JPEG Metadata
*
* Revision: 1.00
*
* URL: http://electronics.ozhiker.com
*
* Copyright: Copyright Evan Hunter 2004
* This file may be used freely for non-commercial purposes.For
* commercial uses please contact the author: evan@ozhiker.com
*
******************************************************************************/
// Add the parser and interpreter functions to the list of Makernote parsers and interpreters.
$GLOBALS['Makernote_Function_Array']['Read_Makernote_Tag'][] = "get_Canon_Makernote";
$GLOBALS['Makernote_Function_Array']['get_Makernote_Text_Value'][] = "get_Canon_Text_Value";
$GLOBALS['Makernote_Function_Array']['Interpret_Makernote_to_HTML'][] = "get_Canon_Makernote_Html";
/******************************************************************************
*
* Function: get_Canon_Makernote
*
* Description: Decodes the Makernote tag and returns the new tag with the decoded
* information attached. Returns false if this is not a makernote
* that can be processed with this script
*
* Parameters: Makernote_Tag - the element of an EXIF array containing the
* makernote, as returned from get_EXIF_JPEG
* EXIF_Array - the entire EXIF array containing the
* makernote, as returned from get_EXIF_JPEG, in
* case more information is required for decoding
* filehnd - an open file handle for the file containing the
* makernote - does not have to be positioned at the
* start of the makernote
* Make_Field - The contents of the EXIF Make field, to aid
* determining whether this script can decode
* the makernote
*
*
* Returns: Makernote_Tag - the Makernote_Tag from the parameters, but
* modified to contain the decoded information
* FALSE - If this script could not decode the makernote, or if
* an error occured in decoding
*
******************************************************************************/
function get_Canon_Makernote( $Makernote_Tag, $EXIF_Array, $filehnd, $Make_Field )
{
// Check if the Make Field contains the word Canon
if ( stristr( $Make_Field, "Canon" ) === FALSE )
{
// Canon not found in Make Field - can't process this
return FALSE;
}
// Seek to the start of the IFD
fseek($filehnd, $Makernote_Tag['Tiff Offset'] + $Makernote_Tag['Offset'] );
// Read the IFD(s) into an array
$Makernote_Tag['Decoded Data'] = read_Multiple_IFDs( $filehnd, $Makernote_Tag['Tiff Offset'], $Makernote_Tag['ByteAlign'], "Canon" );
// Save some information into the Tag element to aid interpretation
$Makernote_Tag['Decoded'] = TRUE;
$Makernote_Tag['Makernote Type'] = "Canon";
$Makernote_Tag['Makernote Tags'] = "Canon";
// Return the new tag
return $Makernote_Tag;
}
/******************************************************************************
* End of Function: get_Canon_Makernote
******************************************************************************/
/******************************************************************************
*
* Function: get_Canon_Makernote_Html
*
* Description: Attempts to interpret a makernote into html. Returns false if
* it is not a makernote that can be processed with this script
*
* Parameters: Makernote_Tag - the element of an EXIF array containing the
* makernote, as returned from get_EXIF_JPEG
* filename - the name of the JPEG file being processed ( used
* by scripts which display embedded thumbnails)
*
*
* Returns: output - the html representing the makernote
* FALSE - If this script could not interpret the makernote, or if
* an error occured in decoding
*
******************************************************************************/
function get_Canon_Makernote_Html( $Makernote_tag, $filename )
{
// Check that this makernote uses canon tags
if ( $Makernote_tag['Makernote Type'] != "Canon" )
{
// Makernote doesn't use Canon tags - cant Interpret it
return FALSE;
}
// Interpret the IFD to html
return interpret_IFD( $Makernote_tag['Decoded Data'][0], $filename );
}
/******************************************************************************
* End of Function: get_Canon_Makernote_Html
******************************************************************************/
/******************************************************************************
*
* Function: get_Canon_Text_Value
*
* Description: Provides a text value for any tag marked as special for makernotes
* that this script can decode. Returns false if this is not a makernote
* that can be processed with this script
*
* Parameters: Exif_Tag - the element of an the Makernote array containing the
* tag in question, as returned from get_Canon_Makernote
* Tag_Definitions_Name - The name of the Tag Definitions group
* within the global array IFD_Tag_Definitions
*
*
* Returns: output - the text value for the tag
* FALSE - If this script could not decode the makernote, or if
* an error occured in decoding
*
******************************************************************************/
function get_Canon_Text_Value( $Exif_Tag, $Tag_Definitions_Name )
{
// Check that the tag uses Canon Definitions
if ( $Tag_Definitions_Name != "Canon" )
{
// Tag doesn't use Canon definintions - can't process it
return FALSE;
}
$Tag_ID = $Exif_Tag['Tag Number'];
// Process the special tag according to the tag number
switch ( $Tag_ID )
{
// CAMERA SETTINGS 1
case 1:
// Create an output string
$output_str = "";
// Cycle through each of the camera settings Values
foreach( $Exif_Tag['Data'] as $offset => $value )
{
// Check that the value exists
if ( $value !== NULL )
{
// Process the settings according to their offset
if ( $offset == 0 )
{
// Do Not Show this Field ( Number of Bytes in Tag )
}
else if ( $offset == 2 )
{
if ( $value == 0 )
{
$output_str .= "Self timer not used\n";
}
else
{
$output_str .= "Self timer length : ". ($value/10) . " seconds\n";
}
}
else if ( ( $offset == 23 ) && ( $Exif_Tag['Data'][25] != 0 ))
{
$output_str .= "Maximum Focal Length of Lens: " . ($value / $Exif_Tag['Data'][25]) . "mm\n";
}
else if ( ( $offset == 24 ) && ( $Exif_Tag['Data'][25] != 0 ))
{
$output_str .= "Minimum Focal Length of Lens: " . ($value / $Exif_Tag['Data'][25]) . "mm\n";
}
else if ( $offset == 25 )
{
// Do Not Show this Field ( Focal Length units per mm )
}
else if ( $offset == 29 )
{
if ( $value & 0x4000 == 0x4000 )
{
$output_str .= "External E-TTL Flash\n";
}
if ( $value & 0x2000 == 0x2000 )
{
$output_str .= "Internal Flash\n";
}
if ( $value & 0x0800 == 0x0800 )
{
$output_str .= "Flash FP sync used\n";
}
if ( $value & 0x0080 == 0x0080 )
{
$output_str .= "Second (Rear) curtain flash sync used\n";
}
if ( $value & 0x0008 == 0x0008 )
{
$output_str .= "Flash FP sync enabled\n";
}
}
else if ( array_key_exists( $offset, $GLOBALS[ "Canon_Camera_Settings_1_Tag_Values" ] ) )
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -