Finding keywords in image data

折月煮酒 提交于 2020-01-05 09:33:45

问题


I kinda ran into a problem, I'm working on a small image site for a photographer, the photographer uses photoshop to store information into the image.
Information such as image data, location, descriptions, ...

He's been doing this since CS3.

When user uploads a picture to the site, he wants everything to go automatically, so I was trying to read out all the keywords, like this:

$size = getimagesize($path, $info);
if(isset($info['APP13'])) {
    $iptc = iptcparse($info['APP13']);

    if(isset($iptc['2#025'])) {
        $tagsArr = $iptc['2#025'];
    } else {
         $tagsArr = array();
    }
}

This all works fine for images saved in CS5, but for images saved in CS3 it fails, even though I'm 100% sure the keywords are in there.

To give an example:
This one fails - http://woutr.be/naturalight/uploads/ea568fea3e7eb1448d30fb823f477aac.jpg
This one works - http://woutr.be/naturalight/uploads/e3f2e6db833803a77eb75aae16e8c8ec.jpg

I've been looking into this for a few days, but I can't figure out why this doesn't work for some images.


回答1:


I know you had mentioned that you tried ozhiker's code before, but I was able to pull a full list of keywords from both images using Photoshop_File_Info.php

http://www.ozhiker.com/electronics/pjmt/download.html

From file 1:

amphibian aquatic belgium close-up common frog europe frog froglet leaf metamorphosis pond reproduction silhouette spring veins water waterplantsamfibie belgie blad bruine kikker europa kikker kikkervisje metamorfose nerven poel silhouet vijver voorjaar voortplanting watermilieu waterplanten

From file 2:

finland abstract boom tree bomen trees boomstam dromerig effect soft zacht kleur colour lijnen lines patroon pattern patronen patterns scenic picturesque sfeer atmosphere bos forest naaldhout conifer pine forest blauw blue lijnen lines sparrenbos fijnsparrenbos firtree spar fijnspar picea abies norway spruce habitat national park alps europe nationaal park nature natuur woud vegetatie plant vegetation planting tree boom boslandschap wildernis monochrome movement beweging




回答2:


I just examined both of your files and the failing file does not have the keywords that the working file has. The failing file describes a "Rana Temporaria" without keywords, while the working file describes a "Pine Forest" with a long list of keywords such as "alps, vegetation, nature". They both have a JPEG APP13 data segment, but the contents of those segments are quite different.




回答3:


Did you try the exif_ functions. They can read the headers of an image.

http://php.net/manual/en/book.exif.php



来源:https://stackoverflow.com/questions/9050856/finding-keywords-in-image-data

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!