PhpDig.net

What is PhpDig?
PhpDig is a PHP MySQL based
Web Spider & Search Engine.




iptcparse

Name

iptcparse — Parses a binary IIM block into human-readable tags.

Synopsis

mixed iptcparse(iptc_block);
string iptc_block:

Returns

Array of parsed IPTC (International Press and Telecommunications Council) format data; FALSE on error

Description

iptcparse() is used to convert blocks of Information Interchange Model (IIM) format data into arrays of single tags. IIM is a format that allows editorial meta-data (such as author name and copyright information) to be directly embedded within an image. Developers are most likely to encounter this kind of data in JPEG files that have been authored in Adobe PhotoShop.

The IIM data can be extracted from an image by using the getimagesize() function. (See the following usage examples.)

Note

As of PHP 4.0.4, iptcparse() is not yet complete. To get full use of the function, you should study the IIM documentation (available from http://www.iptc.org/). To get access to the full range of IIM data, direct modification to the PHP source code is required.



Version

PHP Version: 3.0.6+, 4+

Example

Example 759. Extract the copyright information from a block of IIM data

<?php
function iim_get_copyright ($img) {
    # Older versions of PHP may want $IIM to be passed by reference
    # In these cases use &$IIM in place of $IIM in the following function call
    @ getimagesize ($img, $IIM);

    # If $img does not refer to a valid image or does not contain IIM data, then exit.
    if (! is_array ($IIM))
        return FALSE;

    # Loop through the IIM data blocks
    foreach ($IIM as $block) {
        # Convert the binary IIM block into an array of tags
        $tags = @ iptcparse ($block);

        # If the result of the conversion is not an array,
        # skip to the next IIM block
        if (! is_array ($tags))
            continue;
        
        # If the result is an array,
        # see if one of the tags in the array corresponds to copyright data
        # '2#116' is the tag that represents copyright data
        foreach ($tags as $key => $value) {
            if ('2#116' == $key) {
                return implode (', ', $value);
            }
        }
    }
}

print iim_get_copyright ('test.jpg');
?>



PHP Functions Essential Reference. Copyright © 2002 by New Riders Publishing (Authors: Zak Greant, Graeme Merrall, Torben Wilson, Brett Michlitsch). This material may be distributed only subject to the terms and conditions set forth in the Open Publication License, v1.0 or later (the latest version is presently available at http://www.opencontent.org/openpub/). The authors of this book have elected not to choose any options under the OPL. This online book was obtained from http://www.fooassociates.com/phpfer/ and is designed to provide information about the PHP programming language, focusing on PHP version 4.0.4 for the most part. The information is provided on an as-is basis, and no warranty or fitness is implied. All persons and entities shall have neither liability nor responsibility to any person or entity with respect to any loss or damage arising from the information contained in this book.

Powered by: vBulletin Version 3.0.7
Copyright ©2000 - 2005, Jelsoft Enterprises Ltd.
Copyright © 2001 - 2005, ThinkDing LLC. All Rights Reserved.