$PI_tag, 'Data' => substr($data_part, $a*6+2, 4) , 'Decoded' => False ); } } } // Return the updated tag return $newtag; } /****************************************************************************** * End of Function: Decode_PIM ******************************************************************************/ /****************************************************************************** * * Function: Encode_PIM * * Description: Encodes the contents of a EXIF tag containing Print Image * Matching information, and returns the contents as a packed binary string * * Parameters: tag - An EXIF tag containing Print Image Matching information * as from get_EXIF_JPEG * Byte_Align - the Byte alignment to use - "MM" or "II" * * Returns: packed_data - The packed binary string representing the PIM data * ******************************************************************************/ function Encode_PIM( $tag, $Byte_Align) { // Create a string to receive the packed data $packed_data = ""; // Check that this tag is for Print Image Matching Info if ( $tag['Type'] == "PIM" ) { // Check that the tag has been decoded - otherwise we don't need to do anything if ( ( is_array( $tag['Data'] ) ) && ( count ( $tag['Data'] ) > 0 ) ) { // Add the header to the packed data $packed_data .= "PrintIM\x00"; // Add the version to the packed data $packed_data .= $tag['Data']['Version'] . "\x00"; // Create a string to receive the tag data $tag_data_str = ""; // Cycle through each tag $tag_count = 0; foreach( $tag['Data'] as $key => $curr_tag ) { // Make sure this is a tag and not supplementary info if ( is_numeric( $key ) ) { // Count how many tags are created $tag_count++; // Add the tag number to the packed tag data $tag_data_str .= put_IFD_Data_Type( $curr_tag['Tag Number'], 3, $Byte_Align ); // Add the tag data to the packed tag data $tag_data_str .= $curr_tag['Data']; } } // Add the tag count to the packed data $packed_data .= put_IFD_Data_Type( $tag_count, 3, $Byte_Align ); // Add the packed tag data to the packed data $packed_data .= $tag_data_str; } } // Return the resulting packed data return $packed_data; } /****************************************************************************** * End of Function: Encode_PIM ******************************************************************************/ /****************************************************************************** * * Function: get_PIM_Text_Value * * Description: Interprets the contents of a EXIF tag containing Print Image * Matching information, and returns content as as a text string * * Parameters: tag - An EXIF tag containing Print Image Matching information * as from get_EXIF_JPEG * Tag_Definitions_Name - The name of the Tag Definitions group * within the global array IFD_Tag_Definitions * * Returns: output_str - The text string representing the PIM info * ******************************************************************************/ function get_PIM_Text_Value( $Tag, $Tag_Definitions_Name ) { // Create a string to receive the output $output_str = ""; // Check if the PIM tag has been decoded if ( ( is_array( $Tag['Data'] ) ) && ( count ( $Tag['Data'] ) > 0 ) ) { // The tag has been decoded // Add the Version to the output $output_str = "Version: " . $Tag['Data']['Version'] . "\n"; // Check if the user wants to hide unknown tags if ( $GLOBALS['HIDE_UNKNOWN_TAGS'] == FALSE ) { // The user wants to see unknown tags // Cycle through each tag foreach ( $Tag['Data'] as $PIM_tag_Key => $PIM_tag ) { // Check that the tag is not the version array element if ( $PIM_tag_Key !== 'Version' ) { // Add the tag to the output $output_str .= "Unknown Tag " . $PIM_tag['Tag Number'] . ": (" . strlen( $PIM_tag['Data'] ) . " bytes of data)\n"; } } } } // Return the output text return $output_str; } /****************************************************************************** * End of Function: get_PIM_Text_Value ******************************************************************************/ ?>