⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 photoshop_irb.php

📁 CMS系统 提供学习研究修改最好了 比流行的一些CMS简单 但是更容易理解 是帮助你学习PHPCMS系统的好东东哦
💻 PHP
📖 第 1 页 / 共 5 页
字号:
<?php/******************************************************************************** Filename:     Photoshop_IRB.php** Description:  Provides functions for reading and writing information to/from*               the 'App 13' Photoshop Information Resource Block segment of*               JPEG format files** Author:       Evan Hunter** Date:         23/7/2004** Project:      PHP JPEG Metadata Toolkit** Revision:     1.11** Changes:      1.00 -> 1.02 : changed get_Photoshop_IRB to work with corrupted*                              resource names which Photoshop can still read*               1.02 -> 1.03 : Fixed put_Photoshop_IRB to output "Photoshop 3.0\x00"*                              string with every APP13 segment, not just the first one*               1.03 -> 1.10 : changed get_Photoshop_IRB to fix processing of embedded resource names,*                              after discovering that Photoshop does not process*                              resource names according to the standard :*                              "Adobe Photoshop 6.0 File Formats Specification, Version 6.0, Release 2, November 2000"*                              This is an update to the change 1.00 -> 1.02, which was not fully correct*                              changed put_Photoshop_IRB to fix the writing of embedded resource name,*                              to avoid creating blank resources, and to fix a problem*                              causing the IRB block to be incorrectly positioned if no APP segments existed.*                              changed get_Photoshop_IPTC to initialise the output array correctly.*               1.10 -> 1.11 : Moved code out of get_Photoshop_IRB into new function unpack_Photoshop_IRB_Data*                              to allow reading of IRB blocks embedded within EXIF (for TIFF Files)*                              Moved code out of put_Photoshop_IRB into new function pack_Photoshop_IRB_Data*                              to allow writing of IRB blocks embedded within EXIF (for TIFF Files)*                              Enabled the usage of $GLOBALS['HIDE_UNKNOWN_TAGS'] to hide unknown resources*                              changed Interpret_IRB_to_HTML to allow thumbnail links to work when*                              toolkit is portable across directories*** URL:          http://electronics.ozhiker.com** Copyright:    Copyright Evan Hunter 2004** License:      This file is part of the PHP JPEG Metadata Toolkit.**               The PHP JPEG Metadata Toolkit is free software; you can*               redistribute it and/or modify it under the terms of the*               GNU General Public License as published by the Free Software*               Foundation; either version 2 of the License, or (at your*               option) any later version.**               The PHP JPEG Metadata Toolkit is distributed in the hope*               that it will be useful, but WITHOUT ANY WARRANTY; without*               even the implied warranty of MERCHANTABILITY or FITNESS*               FOR A PARTICULAR PURPOSE.  See the GNU General Public License*               for more details.**               You should have received a copy of the GNU General Public*               License along with the PHP JPEG Metadata Toolkit; if not,*               write to the Free Software Foundation, Inc., 59 Temple*               Place, Suite 330, Boston, MA  02111-1307  USA**               If you require a different license for commercial or other*               purposes, please contact the author: evan@ozhiker.com*******************************************************************************/// Change: as of version 1.11 - added to ensure the HIDE_UNKNOWN_TAGS variable is set even if EXIF.php is not includedif ( !isset( $GLOBALS['HIDE_UNKNOWN_TAGS'] ) )     $GLOBALS['HIDE_UNKNOWN_TAGS']= FALSE;include_once 'IPTC.php';include_once 'Unicode.php';// TODO: Many Photoshop IRB resources not interpeted// TODO: Obtain a copy of the Photoshop CS File Format Specification// TODO: Find out what Photoshop IRB resources 1061, 1062 & 1064 are// TODO: Test get_Photoshop_IRB and put_Photoshop_IRB with multiple APP13 segments/******************************************************************************** Function:     get_Photoshop_IRB** Description:  Retrieves the Photoshop Information Resource Block (IRB) information*               from an App13 JPEG segment and returns it as an array. This may*               include IPTC-NAA IIM Information. Uses information*               supplied by the get_jpeg_header_data function** Parameters:   jpeg_header_data - a JPEG header data array in the same format*                                  as from get_jpeg_header_data** Returns:      IRBdata - The array of Photoshop IRB records*               FALSE - if an APP 13 Photoshop IRB segment could not be found,*                       or if an error occured*******************************************************************************/function get_Photoshop_IRB( $jpeg_header_data ){        // Photoshop Image Resource blocks can span several JPEG APP13 segments, so we need to join them up if there are more than one        $joined_IRB = "";        //Cycle through the header segments        for( $i = 0; $i < count( $jpeg_header_data ); $i++ )        {                // If we find an APP13 header,                if ( strcmp ( $jpeg_header_data[$i]['SegName'], "APP13" ) == 0 )                {                        // And if it has the photoshop label,                        if( strncmp ( $jpeg_header_data[$i]['SegData'], "Photoshop 3.0\x00", 14) == 0 )                        {                                // join it to the other previous IRB data                                $joined_IRB .= substr ( $jpeg_header_data[$i]['SegData'], 14 );                        }                }        }        // If there was some Photoshop IRB information found,        if ( $joined_IRB != "" )        {                // Found a Photoshop Image Resource Block - extract it.                // Change: Moved code into unpack_Photoshop_IRB_Data to allow TIFF reading as of 1.11                return unpack_Photoshop_IRB_Data( $joined_IRB );        }        else        {                // No Photoshop IRB found                return FALSE;        }}/******************************************************************************* End of Function:     get_Photoshop_IRB******************************************************************************//******************************************************************************** Function:     put_Photoshop_IRB** Description:  Adds or modifies the Photoshop Information Resource Block (IRB)*               information from an App13 JPEG segment. If a Photoshop IRB already*               exists, it is replaced, otherwise a new one is inserted, using the*               supplied data. Uses information supplied by the get_jpeg_header_data*               function** Parameters:   jpeg_header_data - a JPEG header data array in the same format*                                  as from get_jpeg_header_data*               new_IRB_data - an array of the data to be stored in the Photoshop*                              IRB segment. Should be in the same format as received*                              from get_Photoshop_IRB** Returns:      jpeg_header_data - the JPEG header data array with the*                                  Photoshop IRB added.*               FALSE - if an error occured*******************************************************************************/function put_Photoshop_IRB( $jpeg_header_data, $new_IRB_data ){        // Delete all existing Photoshop IRB blocks - the new one will replace them        //Cycle through the header segments        for( $i = 0; $i < count( $jpeg_header_data ) ; $i++ )        {                // If we find an APP13 header,                if ( strcmp ( $jpeg_header_data[$i]['SegName'], "APP13" ) == 0 )                {                        // And if it has the photoshop label,                        if( strncmp ( $jpeg_header_data[$i]['SegData'], "Photoshop 3.0\x00", 14) == 0 )                        {                                // Delete the block information - it needs to be rebuilt                                array_splice( $jpeg_header_data, $i, 1 );                        }                }        }        // Now we have deleted the pre-existing blocks        // Retrieve the Packed Photoshop IRB Data        // Change: Moved code into pack_Photoshop_IRB_Data to allow TIFF writing as of 1.11        $packed_IRB_data = pack_Photoshop_IRB_Data( $new_IRB_data );        // Change : This section changed to fix incorrect positioning of IRB segment, as of revision 1.10        //          when there are no APP segments present        //Cycle through the header segments in reverse order (to find where to put the APP13 block - after any APP0 to APP12 blocks)        $i = count( $jpeg_header_data ) - 1;        while (( $i >= 0 ) && ( ( $jpeg_header_data[$i]['SegType'] > 0xED ) || ( $jpeg_header_data[$i]['SegType'] < 0xE0 ) ) )        {                $i--;        }        // Cycle through the packed output data until it's size is less than 32000 bytes, outputting each 32000 byte block to an APP13 segment        while ( strlen( $packed_IRB_data ) > 32000 )        {                // Change: Fixed put_Photoshop_IRB to output "Photoshop 3.0\x00" string with every APP13 segment, not just the first one, as of 1.03                // Write a 32000 byte APP13 segment                array_splice($jpeg_header_data, $i +1  , 0, array(  "SegType" => 0xED,                                                                "SegName" => "APP13",                                                                "SegDesc" => $GLOBALS[ "JPEG_Segment_Descriptions" ][ 0xED ],                                                                "SegData" => "Photoshop 3.0\x00" . substr( $packed_IRB_data,0,32000) ) );                // Delete the 32000 bytes from the packed output data, that were just output                $packed_IRB_data = substr_replace($packed_IRB_data, '', 0, 32000);                $i++;        }        // Write the last block of packed output data to an APP13 segment - Note array_splice doesn't work with multidimensional arrays, hence inserting a blank string

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -