PHP.mk документација

iptcparse

Почист и полокален преглед на PHP референцата, со задржана структура од PHP.net и подобра читливост за примери, секции и белешки.

function.iptcparse.php PHP.net прокси Преводот се освежува
Оригинал на PHP.net
Патека function.iptcparse.php Локална патека за оваа страница.
Извор php.net/manual/en Оригиналниот HTML се реупотребува и локално се стилизира.
Режим Прокси + превод во позадина Кодовите, табелите и белешките остануваат читливи во истиот тек.
iptcparse

Референца за `function.iptcparse.php` со подобрена типографија и навигација.

function.iptcparse.php

iptcparse

(PHP 4, PHP 5, PHP 7, PHP 8)

iptcparse(PHP 4, PHP 5, PHP 7, PHP 8)

= NULL

iptcparse(string $iptc_block): array|false

Парсира бинарен IPTC блок во поединечни ознаки Парсира еден » IPTC

Параметри

iptc_block

блок во неговите поединечни ознаки.

Вратени вредности

Бинарен IPTC блок. false Враќа низа користејќи го маркер за ознака како индекс и вредноста како вредност. Враќа

Примери

при грешка или ако не се најдени IPTC податоци. getimagesize()

<?php
$size
= getimagesize('./test.jpg', $info);
if(isset(
$info['APP13']))
{
$iptc = iptcparse($info['APP13']);
var_dump($iptc);
}
?>

Белешки

Забелешка:

Оваа функција не бара GD библиотека за слики.

Белешки од корисници 9 белешки

Анонимен
пред 23 години
Just to add to the above response, he missed a couple of IPTC tags:

Keywords:
$iptc["2#025"][n];   (there is a list of keywords)

Caption Writer:
$iptc["2#122"][0];

Just figured I'd note it, as the keywords can be quite important for database applications.  I got these by extracting IPTC tags from a Photoshop 6.0 file, so hopefully they are standardized ;)
nikolam3244 at gmail dot com
12 години пред
I've managed to update "pkrohn at daemonize dot com" array, after 12 years since initial publication.

If you want to change some of IPCT header-strings into something more human-readable, try to use array similar to this:

$iptcHeaderArray = array
(
    '2#005'=>'DocumentTitle',
    '2#010'=>'Urgency',
    '2#015'=>'Category',
    '2#020'=>'Subcategories',
    '2#040'=>'SpecialInstructions',
    '2#055'=>'CreationDate',
    '2#080'=>'AuthorByline',
    '2#085'=>'AuthorTitle',
    '2#090'=>'City',
    '2#095'=>'State',
    '2#101'=>'Country',
    '2#103'=>'OTR',
    '2#105'=>'Headline',
    '2#110'=>'Source',
    '2#115'=>'PhotoSource',
    '2#116'=>'Copyright',
    '2#120'=>'Caption',
    '2#122'=>'CaptionWriter'
);
Пример #1 iptcparse() употребено заедно со
21 години пред
To import IPTC keywords (which are stored in an array) into a scalar, try this sort of approach:

$keywordcount = count($iptc["2#025"]);
for ($i=0; $i<$keywordcount; $i++) $keywords .= $iptc["2#025"][$i] . " ";

(you could strip the trailing space if you wanted).

If you are importing data from some Mac applications, they may put chr(213) into strings to access a closing quote character. This prints as a captial O with a tilde above it in a web browser or on Windows. You can fix this with:

function ConvertChars($in)
{
        return str_replace(chr(213),"'",$in);
}

We use aspects of this code at www.thirdlight.com when parsing IPTC tags. XMP seems to be the better solution these days (being XML based is a great improvement!!).
www.peterdebruin.net
пред 14 години
Nowadays IPTC captions may be encoded in UTF-8.
In that case, IPTC tag CodedCharacterSet would be set to "ESC % G".
This tag has tag marker "1#090".
To decode such a caption into simple ISO-8859-1, you could use the following code:

<?php
$IPTC_Caption = "";
$size = getimagesize( $image_path, $info );
if (isset($info["APP13"])) {
    if($iptc = iptcparse( $info["APP13"] ) ) {
        $IPTC_Caption = str_replace( "\000", "", $iptc["2#120"][0] );
        if(isset($iptc["1#090"]) && $iptc["1#090"][0] == "\x1B%G")
            $IPTC_Caption = utf8_decode($IPTC_Caption);
    }
}
?>

Of course, this will only preserve ISO-8859-1 characters.
For proper Unicode support, you should convert UTF-8 byte sequences into HTML character entities, or encode the whole web page in UTF-8.
Анонимен
пред 22 години
View all availiable IPCT Data

function output_iptc_data( $image_path ) {    
    $size = getimagesize ( $image_path, $info);        
     if(is_array($info)) {    
        $iptc = iptcparse($info["APP13"]);
        foreach (array_keys($iptc) as $s) {              
            $c = count ($iptc[$s]);
            for ($i=0; $i <$c; $i++) 
            {
                echo $s.' = '.$iptc[$s][$i].'<br>';
            }
        }                  
    }             
}
мајкл велс
21 години пред
You might have noticed that several metadata fields in Photoshop are not available via IPTC. 

I have written a library "PHP JPEG Metadata Toolkit" which fixes this problem as it allows reading, writing and interpreting of virtually any type of metadata, including these missing fields.

Try it out, and download it at: 
http://www.ozhiker.com/electronics/pjmt/index.html
еван на nospam точка ozhiker точка com
figroc at gmail dot com
This took me longer than it ought to to figure out. Very handy for handling a stream of photos where the info you want is in the IPTC header. This example passes by reference, for which PHP4 will yell at you. If your need to write into the header, check out the Image::IPTCInfo Perl module.

$size = GetImageSize ("$image_name",&$info);
$iptc = iptcparse ($info["APP13"]);
if (isset($info["APP13"])) {
    $iptc = iptcparse($info["APP13"]){
        if (is_array($iptc)) {
        $caption = $iptc["2#120"][0];
    $graphic_name = $iptc["2#005"][0];
        $urgency = $iptc["2#010"][0];    
    $category = $iptc["2#015"][0];    
    // note that sometimes supp_categories contans multiple entries
$supp_categories = $iptc["2#020"][0];
$spec_instr = $iptc["2#040"][0];
$creation_date = $iptc["2#055"][0];
$photog = $iptc["2#080"][0];
$credit_byline_title = $iptc["2#085"][0];
$city = $iptc["2#090"][0];
$state = $iptc["2#095"][0];
$country = $iptc["2#101"][0];
$otr = $iptc["2#103"][0];
$headline = $iptc["2#105"][0];
$source = $iptc["2#110"][0];
$photo_source = $iptc["2#115"][0];
$caption = $iptc["2#120"][0];    }}
пкрохн на daemonize точка com
пред 23 години
If you are not sure where a particular value you entered into the IPTC block in photoshop or any other software is being stored, simply run a foreach loop thru the block and find out:

(Insert a new paragraph in the beggening of the first echo)

$size = GetImageSize ("testimg.jpg", &$info);
$iptc = iptcparse($info["APP13"]);

foreach($iptc as $key => $value)
{
    echo "<b>IPTC Key:</b> $key <b>Contents:</b> ";
    foreach($value as $innerkey => $innervalue)
    {
        if( ($innerkey+1) != count($value) )
            echo "$innervalue, ";
        else
            echo "$innervalue";
    }
}
Сцин
пред 8 години
Is there a way to sort by keyword??? 
thx for help

<?php
    $files = glob("*.*");
    for ($i=0; $i<count($files); $i++)
     {
       $image = $files[$i];
$supported_file = array('jpg',);
$ext = strtolower(pathinfo($image, PATHINFO_EXTENSION));
        
$img = basename($image);
$size = getimagesize($img, $info);
if(isset($info['APP13']))
{
    $iptc = iptcparse($info['APP13']);
    $keyword0 = $iptc["2#025"][0];
    if($keyword0 == "") {$keyword0 = "";} else {$keyword0 = $keyword0;}
    $keywords = $keyword0;
}  
        
if (in_array($ext, $supported_file)) {
           echo '           
<div class="col-xs-12 col-sm-6 col-md-6 col-lg-4 col-xl-3 outerContent" id="theme"><a class="example-image-link" href="',$img,'" data-lightbox="example-set" data-title="'.$keywords.'"><div class="innerContent" style="background-image: url(',$img,')"></div></a></div>';
           $keywords = "" ;
           } else {
               continue;
           }
         }
?>
Навигација

Прелистувај сродни теми и функции.

На оваа страница

Автоматски outline од активната документација.

Насловите ќе се појават тука по вчитување.

Попрегледно читање

Примерите, changelog табелите и user notes се визуелно издвоени за да не се губат во долгата содржина.

Брз совет Користи го outline-от Скокни директно на главните секции од активната страница.
Извор Оригиналниот линк останува достапен Кога ти треба целосен upstream context, отвори го PHP.net во нов tab.