IPTC tag import enhancement suggestion

Discussion corner for Developers of Serendipity.
VladaAjgl
Regular
Posts: 44
Joined: Mon Nov 19, 2007 10:00 pm
Contact:

IPTC tag import enhancement suggestion

Post by VladaAjgl »

Hi everybody,
I found some bugs or bad functionality of reading IPTC tags of images in image gallery. I made some fixes in my blog and I propose these fixes also to you.
The main trouble was in the file (include/function_images.inc.php) at line about 2500, where you get the meta data (EXIF and IPTC) from the thumbnail file, not from the original file - see next line:

Code: Select all

$file['dim'] = @getimagesize($file['full_thumb'],$file['header']);
I is maybe the functionality of resize function, that it copies the exif tags, but not IPTC tags, so you get NEVER any IPTC header. I think the correct solution is to read the headers from original file.
I also fixed the parsing of IPTC date and time format, which has not the same format as the EXIF date tag.
Finally I found that the IPTC keys assigned to the database fields such as "short description" or "title" are not the ones that one would attend intuitively. So I changed this assignement to the more predictable ones.
The file as I use it on my blog is to download at:
http://vlada.ajgl.cz/myplugins/IPTC_1.zip
Bye Vladimir
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: IPTC tag import enhancement suggestion

Post by garvinhicking »

Hi!

Thanks for sharing this! I have a question tough.

You changed several of those lines:

Code: Select all

$media['base_property'][$propkey]['val'] = serendipity_pick
Key($media['metadata'], 'Title', $media['internal']['realname']);
When I developed the keyword parsing, I used files created by Adobe Photoshop which used "Title" instead of "ObjectName" and others you are using. Could it be that your IPTC-matchmethod would render usual EXIF-Files unusable for their default fields?

I think there should be a check to test if "ObjectName" is not empty, and only then use it - in the other case, fall back to "Title"?

Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
VladaAjgl
Regular
Posts: 44
Joined: Mon Nov 19, 2007 10:00 pm
Contact:

Re: IPTC tag import enhancement suggestion

Post by VladaAjgl »

In fact I do not insist that it should be the exact way I suggested it. This is not question to make thousands of possibilities what to parse where. It is to make a decision, after the debat, which iptc tag will be linkde to which s9y image field.

I searched web for description, what each IPTC field should containt (see eg. http://www.iptc.org/photometadata/, one of the links on the top of the page ). The question is, what should contain the serendipity fields "title", "short description" and "long description".

Concerning "title", it is my mistake, I used the taging program, that in user interface says "title", but saves this value as "ObjectName". Otherways if you see the description under the link, IPTC tag "title" should be rather a technical description, such as filename. Maybe in serendipity, some more human description should be used as a serendipity "title". Than maybe iptc tag "headline" would be more convenient.

And then the next two fields. Originally, iptc "kewords" were parsed into s9y "short description" and iptc "location" into s9y "long descripiton". I was missing some more verbose human description, such as iptc "description" that i linked in my version to s9y "short description". And using the third field, s9y "long description" for storing some technic data is in my opinion ok. Question is, which data to parse into it.

Regards Vladimir
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: IPTC tag import enhancement suggestion

Post by garvinhicking »

Hi!

Hm, I rarely work with metadata so: I don't know :-D

What happens with the EXIF tags? Is there some way to detect if the files uses EXIF or IPTC and choose the proper tags depending on that?

I'm open to suggestions, but I think we should definitely implement some checks to use other fields, if the preferred field has an empty value?

Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
VladaAjgl
Regular
Posts: 44
Joined: Mon Nov 19, 2007 10:00 pm
Contact:

Re: IPTC tag import enhancement suggestion

Post by VladaAjgl »

garvinhicking wrote:What happens with the EXIF tags? Is there some way to detect if the files uses EXIF or IPTC and choose the proper tags depending on that?
:-) Exif and Iptc tags are two different tags that do not collide:-) Exif contains mainly information about camera, focus lengths, flas settings etc. and Iptc contains (should contain) info about what is on the picture, who is author. So if there are both types of tag in the picture, they are both printed.

Remark: S9y compares whether there are the exif and iptc tags that have the same name and content -> then it deletes the duplicate iptc tag.

Regards
Vladimir
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: IPTC tag import enhancement suggestion

Post by garvinhicking »

Hi!

I just committed your patch with some modifications to SVN, so that a global variable can be used to set your own special preference. Can you check it out?

Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
VladaAjgl
Regular
Posts: 44
Joined: Mon Nov 19, 2007 10:00 pm
Contact:

Re: IPTC tag import enhancement suggestion

Post by VladaAjgl »

Hi,
I checked it and did not find any error. Pretty nice solution:-)
Vladimir
Don Chambers
Regular
Posts: 3652
Joined: Mon Feb 13, 2006 2:40 am
Location: Chicago, IL, USA
Contact:

Post by Don Chambers »

Is this image metadata smartified?
=Don=
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post by garvinhicking »

Hi!
Don Chambers wrote:Is this image metadata smartified?
Yes, within the context of the media_*.tpl files.

Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
Don Chambers
Regular
Posts: 3652
Joined: Mon Feb 13, 2006 2:40 am
Location: Chicago, IL, USA
Contact:

Post by Don Chambers »

Good grief - what sort of pit did I fall into here??!!! :lol: This stuff looks a bit complicated compared to what I am used to working with.

I presume you mean the admin media*.tpl files?

I guess what I am looking for is a way to get the EXIF or IPTC data for a given image, ideally from the image path. I am also trying to understand the correlation between that data, and the s9y configuration values for "media properties" and "media keywords".
=Don=
Don Chambers
Regular
Posts: 3652
Joined: Mon Feb 13, 2006 2:40 am
Location: Chicago, IL, USA
Contact:

Post by Don Chambers »

1) I uploaded a photo that contains ITPC info to 2 different s9y installs. For one of them, everything is as expected. For the other, it is as if ITPC info does not exist. The image conversion settings are identical between both installs, and both are running the identical release os s9y. Why does one have this info, and the other does not?

2) What is the relationship between the fields entered under configuration for "Media Properties" which defaults to DPI:IMAGE;RUN_LENGTH:VIDEO:AUDIO;DATE;COPYRIGHT;TITLE;COMMENT1:MULTI;COMMENT2:MULTI
And the ITPC or EXIF fields? In other words, how does s9y know to map COMMENT1 to the IPTC Caption?

3) I have the name and path of an image stored in an extended property field. How do I now retrieve the value of COMMENT1 (IPTC Caption) for that image, if the data exists?
=Don=
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post by garvinhicking »

Hi!

1.) What is different then on those 2 installations? There must be a difference. :-)

2.) This is hardcoded in the core. If you use other fields, no IPTC-defaulting will occur, those metafields will then only use manual input. This thread BTW deals with exactly those defaults :)
3) I have the name and path of an image stored in an extended property field. How do I now retrieve the value of COMMENT1 (IPTC Caption) for that image, if the data exists?
You would need to create your own PHP code/plugin for that. No interface/API exists for this. This is the same issue like with the missing API to retrieve images from within smarty. Judebert has added that "imagesize" hack, but this does not deal with other metadata.

Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
Don Chambers
Regular
Posts: 3652
Joined: Mon Feb 13, 2006 2:40 am
Location: Chicago, IL, USA
Contact:

Post by Don Chambers »

Could the php and/or apache configuration have something to do with why I can see this info on one server but not all? Here is the image I am testing, if you wish to check for yourself: http://www.optional-necessity.com/uploa ... t-blue.jpg

Sandbox 1 - running XAMPP:
DPI: 72 [correct]
Associated Date: 2008-03-27 10:15 [correct]
Copyright: Test IPTC Author Field [wrong field]
Title: 00:00:00.00 [incorrect]
Short Comment: 00:00:00.00 [incorrect]
Long Comment: 00:00:00.00 [incorrect]
EXIF/IPTC/XMP: Nothing listed

Optional Necessity - godaddy shared hosting
DPI: 72 [correct]
Associated Date: 2008-03-27 09:34 [incorrect - might be upload time]
Copyright: don chambers [incorrect - this is my s9y author name]
Title: [blank - no value shown]
Short Comment: [blank - no value shown]
Long Comment: [blank - no value shown]
EXIF/IPTC/XMP: EXIF info is listed, but not IPTC
Note: tested on a second godaddy shared account, behavior is identical. Similar behavior on another provider, with the difference being the Copyright notice, like XAMPP, is the author field.

Only installation where everything matches my photoshop image info:
Sandbox 2 - running MAC OS:
DPI: 72
Associated Date: 2008-03-27 10:15
Copyright: Test IPTC Copyright Notice
Title: Test IPTC Title Field
Short Comment: Test IPTC Caption Field
Long Comment: Test IPTC Keywords
EXIF/IPTC/XMP:

IPTC
ObjectName! Test IPTC Title Field
Keywords! Test IPTC Keywords
Photographer! Test IPTC Author Field
Photographer Name! Test IPTC Author Position Field
Creator! Test IPTC Copyright Notice
Description! Test IPTC Caption Field

EXIF
Orientation! Landscape
XResolution! 72
YResolution! 72
Software! Adobe Photoshop 7.0
DateCreated! 2008-03-27 10:15
Creator! Test IPTC Author Field

So, I am at something of a loss here... especially if this is dependent upon configuration outside of s9y, as many/most do not have access to that.
=Don=
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post by garvinhicking »

Hi!
Don Chambers wrote:Could the php and/or apache configuration have something to do
Yes, PHP is involved. You need the PHP function "iptcparse" to be able to use s9y metadata parsing.

A fallback to use "exif_read_data" (also PHP core) is enabled, which can only read EXIF and not IPTC.

Only XMPP metadata can be read without PHP core dependencies.

Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
Don Chambers
Regular
Posts: 3652
Joined: Mon Feb 13, 2006 2:40 am
Location: Chicago, IL, USA
Contact:

Post by Don Chambers »

Thanks again Garvin - so, am I to conclude that these other installations do not have that function enabled? I just looked at my XAMPP php.ini file, and it is not referenced anywhere in that file. Is it not a core php function?
=Don=
Post Reply