📄 photoshop_irb.php
字号:
array_splice($jpeg_header_data, $i + 1 , 0, "" ); $jpeg_header_data[$i + 1] = array( "SegType" => 0xED, "SegName" => "APP13", "SegDesc" => $GLOBALS[ "JPEG_Segment_Descriptions" ][ 0xED ], "SegData" => "Photoshop 3.0\x00" . $packed_IRB_data ); return $jpeg_header_data;}/******************************************************************************* End of Function: put_Photoshop_IRB******************************************************************************//******************************************************************************** Function: get_Photoshop_IPTC** Description: Retrieves IPTC-NAA IIM information from within a Photoshop* IRB (if it is present) and returns it in an array. Uses* information supplied by the get_jpeg_header_data function** Parameters: Photoshop_IRB_data - an array of Photoshop IRB records, as* returned from get_Photoshop_IRB** Returns: IPTC_Data_Out - The array of IPTC-NAA IIM records* FALSE - if an IPTC-NAA IIM record could not be found, or if* an error occured*******************************************************************************/function get_Photoshop_IPTC( $Photoshop_IRB_data ){ // Change: Initialise array correctly, as of revision 1.10 $IPTC_Data_Out = array(); //Cycle through the Photoshop 8BIM records looking for the IPTC-NAA record for( $i = 0; $i < count( $Photoshop_IRB_data ); $i++ ) { // Check if each record is a IPTC record (which has id 0x0404) if ( $Photoshop_IRB_data[$i]['ResID'] == 0x0404 ) { // We've found an IPTC block - Decode it $IPTC_Data_Out = get_IPTC( $Photoshop_IRB_data[$i]['ResData'] ); } } // If there was no records put into the output array, if ( count( $IPTC_Data_Out ) == 0 ) { // Then return false return FALSE; } else { // Otherwise return the array return $IPTC_Data_Out; }}/******************************************************************************* End of Function: get_Photoshop_IPTC******************************************************************************//******************************************************************************** Function: put_Photoshop_IPTC** Description: Inserts a new IPTC-NAA IIM resource into a Photoshop* IRB, or replaces an the existing resource if one is present.* Uses information supplied by the get_Photoshop_IRB function** Parameters: Photoshop_IRB_data - an array of Photoshop IRB records, as* returned from get_Photoshop_IRB, into* which the IPTC-NAA IIM record will be inserted* new_IPTC_block - an array of IPTC-NAA records in the same format* as those returned by get_Photoshop_IPTC** Returns: Photoshop_IRB_data - The Photoshop IRB array with the* IPTC-NAA IIM resource inserted*******************************************************************************/function put_Photoshop_IPTC( $Photoshop_IRB_data, $new_IPTC_block ){ $iptc_block_pos = -1; //Cycle through the 8BIM records looking for the IPTC-NAA record for( $i = 0; $i < count( $Photoshop_IRB_data ); $i++ ) { // Check if each record is a IPTC record (which has id 0x0404) if ( $Photoshop_IRB_data[$i]['ResID'] == 0x0404 ) { // We've found an IPTC block - save the position $iptc_block_pos = $i; } } // If no IPTC block was found, create a new one if ( $iptc_block_pos == -1 ) { // New block position will be at the end of the array $iptc_block_pos = count( $Photoshop_IRB_data ); } // Write the new IRB resource to the Photoshop IRB array with no data $Photoshop_IRB_data[$iptc_block_pos] = array( "ResID" => 0x0404, "ResName" => $GLOBALS['Photoshop_ID_Names'][ 0x0404 ], "ResDesc" => $GLOBALS[ "Photoshop_ID_Descriptions" ][ 0x0404 ], "ResEmbeddedName" => "\x00\x00", "ResData" => put_IPTC( $new_IPTC_block ) ); // Return the modified IRB return $Photoshop_IRB_data;}/******************************************************************************* End of Function: put_Photoshop_IPTC******************************************************************************//******************************************************************************** Function: Interpret_IRB_to_HTML** Description: Generates html showing the information contained in a Photoshop* IRB data array, as retrieved with get_Photoshop_IRB, including* any IPTC-NAA IIM records found.** Please note that the following resource numbers are not currently* decoded: ( Many of these do not apply to JPEG images)* 0x03E9, 0x03EE, 0x03EF, 0x03F0, 0x03F1, 0x03F2, 0x03F6, 0x03F9,* 0x03FA, 0x03FB, 0x03FD, 0x03FE, 0x0400, 0x0401, 0x0402, 0x0405,* 0x040E, 0x040F, 0x0410, 0x0412, 0x0413, 0x0415, 0x0416, 0x0417,* 0x041B, 0x041C, 0x041D, 0x0BB7** ( Also these Obsolete resource numbers)* 0x03E8, 0x03EB, 0x03FC, 0x03FF, 0x0403*** Parameters: IRB_array - a Photoshop IRB data array as from get_Photoshop_IRB* filename - the name of the JPEG file being processed ( used* by the script which displays the Photoshop thumbnail)*** Returns: output_str - the HTML string*******************************************************************************/function Interpret_IRB_to_HTML( $IRB_array, $filename ){ // Create a string to receive the HTML $output_str = ""; // Check if the Photoshop IRB array is valid if ( $IRB_array !== FALSE ) { // Create another string to receive secondary HTML to be appended at the end $secondary_output_str = ""; // Add the Heading to the HTML $output_str .= "<h2 class=\"Photoshop_Main_Heading\">Contains Photoshop Information Resource Block (IRB)</h2>"; // Add Table to the HTML $output_str .= "<table class=\"Photoshop_Table\" border=1>\n"; // Cycle through each of the Photoshop IRB records, creating HTML for each foreach( $IRB_array as $IRB_Resource ) { // Check if the entry is a known Photoshop IRB resource // Get the Name of the Resource if ( array_key_exists( $IRB_Resource['ResID'], $GLOBALS[ "Photoshop_ID_Names" ] ) ) { $Resource_Name = $GLOBALS['Photoshop_ID_Names'][ $IRB_Resource['ResID'] ]; } else { // Change: Added check for $GLOBALS['HIDE_UNKNOWN_TAGS'] to allow hiding of unknown resources as of 1.11 if ( $GLOBALS['HIDE_UNKNOWN_TAGS'] == TRUE ) { continue; } else { // Unknown Resource - Make appropriate name $Resource_Name = "Unknown Resource (". $IRB_Resource['ResID'] .")"; } } // Add HTML for the resource as appropriate switch ( $IRB_Resource['ResID'] ) { case 0x0404 : // IPTC-NAA IIM Record $secondary_output_str .= Interpret_IPTC_to_HTML( get_IPTC( $IRB_Resource['ResData'] ) ); break; case 0x040B : // URL $output_str .= "<tr class=\"Photoshop_Table_Row\"><td class=\"Photoshop_Caption_Cell\">$Resource_Name</td><td class=\"Photoshop_Value_Cell\"><a href=\"" . $IRB_Resource['ResData'] . "\">" . htmlentities( $IRB_Resource['ResData'] ) ."</a></td></tr>\n"; break; case 0x040A : // Copyright Marked if ( hexdec( bin2hex( $IRB_Resource['ResData'] ) ) == 1 ) {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -