📄 konica_minolta.php
字号:
<?php
/******************************************************************************
*
* Filename: konica_minolta.php
*
* Description: Konica/Minolta Makernote Parser
* Provides functions to decode an Konica/Minolta EXIF makernote and
* to interpret the resulting array into html.
*
* Konica/Minolta Makernote Formats:
*
* Type 1:
*
* Field Size Description
* ----------------------------------------------------------------
* Header 3 Bytes "MLY"
* Unknown Data Variable Unknown Data
* ----------------------------------------------------------------
*
* Type 2:
*
* Field Size Description
* ----------------------------------------------------------------
* Header 2 Bytes "KC"
* Unknown Data Variable Unknown Data
* ----------------------------------------------------------------
*
* Type 3:
*
* Field Size Description
* ----------------------------------------------------------------
* Header 8 Bytes "+M+M+M+M"
* Unknown Data Variable Unknown Data
* ----------------------------------------------------------------
*
* Type 4:
*
* Field Size Description
* ----------------------------------------------------------------
* Header 5 Bytes "MINOL"
* Unknown Data Variable Unknown Data
* ----------------------------------------------------------------
*
* Type 5: NO HEADER
*
* Field Size Description
* ----------------------------------------------------------------
* IFD Data Variable Standard IFD with Olympus 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
*
******************************************************************************/
// Konica/Minolta makernote uses Olympus tags - ensure they are included
include_once 'olympus.php';
// Add the parser functions to the list of Makernote parsers . (Interpreting done by Olympus script)
$GLOBALS['Makernote_Function_Array']['Read_Makernote_Tag'][] = "get_Minolta_Makernote";
$GLOBALS['Makernote_Function_Array']['get_Makernote_Text_Value'][] = "get_Minolta_Text_Value";
/******************************************************************************
*
* Function: get_Minolta_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_Minolta_Makernote( $Makernote_Tag, $EXIF_Array, $filehnd, $Make_Field )
{
if ( ( stristr( $Make_Field, "Konica" ) === FALSE ) &&
( stristr( $Make_Field, "Minolta" ) === FALSE ) )
{
// Not a Konica/Minolta Makernote - Cannot decode it
return False;
}
// There are several different headers for a Konica/Minolta Makernote
// Unfortunately only one type can be decoded (the one without a header)
// Check which header exists (if any)
if ( substr( $Makernote_Tag['Data'], 0, 3 ) == "MLY" )
{
// MLY Header - Can't Decode this
return $Makernote_Tag;
}
else if ( substr( $Makernote_Tag['Data'], 0, 2 ) == "KC" )
{
// KC Header - Can't Decode this
return $Makernote_Tag;
}
if ( substr( $Makernote_Tag['Data'], 0, 8 ) == "+M+M+M+M" )
{
// +M+M+M+M Header - Can't Decode this
return $Makernote_Tag;
}
else if ( substr( $Makernote_Tag['Data'], 0, 5 ) == "MINOL" )
{
// MINOL Header - Can't Decode this
return $Makernote_Tag;
}
else
{
// No Header - Decode the IFD
// 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'], "Olympus" );
// Save some information into the Tag element to aid interpretation
$Makernote_Tag['Decoded'] = TRUE;
$Makernote_Tag['Makernote Type'] = "Minolta";
$Makernote_Tag['Makernote Tags'] = "Olympus";
// Return the new tag
return $Makernote_Tag;
}
// Shouldn't get here
return False;
}
/******************************************************************************
* End of Function: get_Minolta_Makernote
******************************************************************************/
/******************************************************************************
*
* Function: get_Minolta_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_Olympus_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_Minolta_Text_Value( $Exif_Tag, $Tag_Definitions_Name )
{
// Check that this Tag uses Olympus type tags - otherwise it cannot be processed here
if ( $Tag_Definitions_Name !== "Olympus" )
{
// Not Olympus Tags - cannot be processed here
return FALSE;
}
// Process the tag acording to it's tag number, to produce a text value
if ( ( $Exif_Tag['Tag Number'] == 0x0001 ) || // Minolta Camera Settings
( $Exif_Tag['Tag Number'] == 0x0003 ) )
{
// Create the output string
$output_str = "";
// Cycle through each camera setting record which are 4 byte Longs
for ( $i = 1; $i*4 <= strlen( $Exif_Tag['Data'] ); $i++)
{
// Exract the current 4 byte Long value (Motorola byte alignment)
$value = get_IFD_Data_Type( substr($Exif_Tag['Data'], ($i-1)*4, 4) , 4, "MM" );
// Corrupt settings can cause huge values, which automatically get
// put into floating point variables instead of integer variables
// Hence Check that this is an integer, as problems will occur if it isn't
if ( is_integer( $value ) )
{
// Check if the current setting number is in the Definitions array
if ( array_key_exists( $i, ($GLOBALS[ "Minolta_Camera_Setting_Definitions" ]) ) === TRUE )
{
// Setting is in definitions array
// Get some of the information from the settings definitions array
$tagname = $GLOBALS[ "Minolta_Camera_Setting_Definitions" ][ $i ][ 'Name' ];
$units = "";
if ( array_key_exists( 'Units', $GLOBALS[ "Minolta_Camera_Setting_Definitions" ][ $i ] ) )
{
$units = $GLOBALS[ "Minolta_Camera_Setting_Definitions" ][ $i ][ 'Units' ];
}
// Check what type of field the setting is, and process accordingly
if ( $GLOBALS[ "Minolta_Camera_Setting_Definitions" ][ $i ]['Type'] == "Lookup" )
{
// This is a lookup table field
// Check if the value read is in the lookup table
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -