New Module: IPTC

gcog

Joined: 2010-05-03
Posts: 12
Posted: Mon, 2010-05-03 19:43

I have created a new module for G3: IPTC

It adds a block like "Photo info" to show IPTC tags.
A new menu IPTC Settings is added to select the tags to show in the IPTC block.
A new task is added to extract IPTC tags from photos.

To install:
- Extract iptc.zip on the modules folder
- Activate the IPTC module
- Run the task to extract IPTC tags
- Chose in the IPTC Settings menu (Parameters in admin mode) the tags you want to show

Hope this can help,
Gilles.

AttachmentSize
iptc.zip12.08 KB
 
inposure
inposure's picture

Joined: 2010-04-23
Posts: 304
Posted: Mon, 2010-05-03 20:34

Not working. For a starter, unzipping the file gives private permissions with some zip programs.

Fixing that, you can install the module, but it doesn't do anything. There is no maintenance thing to run, and there is no menu of any kind.

It is also called iptc_0 for some reason, hardly a good naming convention.

In the folder, there is also a 0 byte file called lib\ which likely shouldn't be there.

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Tue, 2010-05-04 00:17
Quote:
It is also called iptc_0 for some reason, hardly a good naming convention.

That is probably a artifact of the forums renaming files that already exist, hard to get round that without adding some directions or uploading the files to a different place and referencing them here or adding them to the gallery-contrib git repository.

Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Tue, 2010-05-04 00:31

gcog
Thanks for your contribution!

I have started a codex page:
http://codex.gallery2.org/Gallery3:Modules:iptc
Please feel free to flesh out some more info as you see fit. I will add to it as i get some time. Others: feel free to help out in the docs as well.

Dave

_____________________________________________
Blog & G2 || floridave - Gallery Team

 
inposure
inposure's picture

Joined: 2010-04-23
Posts: 304
Posted: Tue, 2010-05-04 18:49

Tried installing again, and now it works. But somehow UTF-8 encoded information is messed up in the process, as with the attached image.

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Wed, 2010-05-05 00:03

1st: I am no encoding expert. That over with....:

From your attached image, using infanview, I see this:
[img]http://gallery.menalto.com/files/IPTC_from_Infanview.jpg[/img]
Does not seem correct to me.

What editor are you using to edit the data in the photo? Does your server have the iconv() function?

Perhaps the original author has more info.

Dave

_____________________________________________
Blog & G2 || floridave - Gallery Team

 
inposure
inposure's picture

Joined: 2010-04-23
Posts: 304
Posted: Wed, 2010-05-05 03:00

Well, I am an encoding expert, goes with the territory. I use Adobe Bridge for adding meta data.

Attached is how this information is presented in Adobe Photoshop and Terminal (raw binary data with header in UTF-8).

The information has been correctly preserved by Gallery when making the resize. Iconv is present:

iconv support enabled
iconv implementation glibc
iconv library version 2.5

[img]http://gallery.menalto.com/files/screen_2.png[/img]
[img]http://gallery.menalto.com/files/screen2.png[/img]

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Wed, 2010-05-05 03:13
Quote:
Well, I am an encoding expert, goes with the territory.

Then perhaps you can look at the code and see why it changes? I would not even know where to start.

Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Wed, 2010-05-05 03:22
Quote:
I use Adobe Bridge for adding meta data.

Viewing with Adobe Photoshop 7.0:
[img]http://gallery.menalto.com/files/IPTC_from_Photoshop.jpg[/img]
Don't know if that helps or confuses more. :-(

Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team

 
inposure
inposure's picture

Joined: 2010-04-23
Posts: 304
Posted: Wed, 2010-05-05 03:58

Well, I am using Photoshop 12... it is a known problem with older versions of Photoshop.

I removed all the iptc tables in the database, plus the iptc vars, but now I can't install the module again. So I can't test it.

But the string 倪阔乐 is what you get when you convert 倪阔乐 from UTF-8 to ISO-8859-1, so the problem is the assumption in helpers/iptc.php based on certain interrupt codes.

Try this with the image:

$size = getimagesize('./IMG_0004.jpg', $info);
if(isset($info['APP13']))
{
$iptc = iptcparse($info['APP13']);
var_dump($iptc);
}

When I do that, both on my local Mac and on a shared server, I get this:

curl -I "http://127.0.0.1/test.php"
HTTP/1.1 200 OK
Date: Wed, 05 May 2010 03:52:49 GMT
Server: Apache/2.2.14 (Unix) mod_ssl/2.2.14 OpenSSL/0.9.8l DAV/2 PHP/5.3.1 mod_fastcgi/2.4.2
X-Powered-By: PHP/5.3.1
Content-Type: text/html; charset=utf-8

curl "http://127.0.0.1/test.php"
array(4) {
["1#090"]=>
array(1) {
[0]=>
string(3) "G"
}
["2#000"]=>
array(1) {
[0]=>
string(2) ""
}
["2#080"]=>
array(1) {
[0]=>
string(28) "Niklas Dougherty / 倪阔乐"
}
["2#116"]=>
array(1) {
[0]=>
string(45) "© 2008 Niklas Dougherty, All rights reserved"
}
}

 
gcog

Joined: 2010-05-03
Posts: 12
Posted: Wed, 2010-05-05 08:06

I am no encoding expert but I found this information:
- There is no encoding information in IPTC tags (The better way will be to use XMP data but it is a lot of work)
- Windows application are using the Latin encoding and Mac application are using the Roman encoding (I don’t know if it is always true?)

My problem is: how can I detect if the IPTC tags in the image are coming from a Windows or Mac application?

 
inposure
inposure's picture

Joined: 2010-04-23
Posts: 304
Posted: Wed, 2010-05-05 10:35

UTF-8 is the standard encoding for Mac OS X, so you really shouldn't do any converting at all, at least not based on the assumptions you have in your code.

Some applications still use encodings such as Latin 1 or even MacRoman (which was used in the former century in Mac OS Classic), but that's really not your problem.

 
gcog

Joined: 2010-05-03
Posts: 12
Posted: Wed, 2010-05-05 10:56

I have some test images with IPTC tags with French accents coming from IView Media Pro (on Windows) and Adobe LightRoom 2 (on Mac OS X)
Adobe LightRoom 2 is not an old application and is using MacRoman encoding for IPTC tags.
So it is my problem.
I know that the assumption I have in my code is only working with some French accents chars.
I hope I can find another way to solve this problem and any help will be welcome.

 
inposure
inposure's picture

Joined: 2010-04-23
Posts: 304
Posted: Wed, 2010-05-05 11:26

That's a bug in Lightroom, no need to propagate it further. Because then you screw up properly encoded stuff for others who don't use Lightroom.

http://forums.adobe.com/message/2590051

 
inposure
inposure's picture

Joined: 2010-04-23
Posts: 304
Posted: Wed, 2010-05-05 11:53

All you need to do, if anything, is to test if the string is UTF-8, otherwise assume that it is Latin-1.

http://se2.php.net/manual/en/function.mb-detect-encoding.php
http://se2.php.net/manual/en/function.mb-check-encoding.php

 
eiapopeia

Joined: 2008-08-04
Posts: 14
Posted: Thu, 2010-05-06 10:20

I'd like to see a patch, too.

Using German umlauts in Lightroom for Windows, they get corrupted when viewing in G3.

The same problem happens, when I import my photos from g2. They read the IPTC-data an fill the caption to the description. Then, the umlaut and all text after it is not shown.

Damn, why don't they all use UTF-8... then we would not have such problems.

 
gcog

Joined: 2010-05-03
Posts: 12
Posted: Thu, 2010-05-06 23:00

I have created a new version for the IPTC module.

Tags are imported from the jpeg XMP segment or if not found from the IPTC segment.
That must solve the special chars problem.

If you are upgrading from the previous version, delete all the iptc_records lines in the gallery database and run the IPTC task to re extract the tags.

I have not a lot of applications to write IPTC data on images to make tests.
If you have problem with some images post the image here.

Hope this can help,
Gilles.

PS: The module name is iptc not iptc_1 so rename the zip file or the module folder.

 
inposure
inposure's picture

Joined: 2010-04-23
Posts: 304
Posted: Fri, 2010-05-07 00:01

Encoding works for me now. However, I'm gonna give you another little bug:

The installer creates a table with this syntax: CREATE TABLE IF NOT EXISTS {iptc_records}

What are the curly braces for? At least on My OS X machine, this prevents the module from installing, and gives a syntax error in MySQL when I enter by hand. Removing them solves the problem.

Then a little something: turning on the module will extract the IPTC records and place the module block in the sidebar, but it will not show anything until you actively choose items in the admin interface. Maybe it would be cool to have a few of the most common fields activated by default, so that the module shows up. Otherwise, it may be confusing to some.

 
gcog

Joined: 2010-05-03
Posts: 12
Posted: Fri, 2010-05-07 07:33

I have copied this code from the module exif: CREATE TABLE IF NOT EXISTS {exif_records}
I'am agree with you the curly braces is a strange syntax.
On my side it is working correctly on my FreeBSD OS running MySQL 6.0.11.
Ok for the activation of the most common fields.

 
inposure
inposure's picture

Joined: 2010-04-23
Posts: 304
Posted: Fri, 2010-05-07 08:55

Also, what is "IPTC Redactor"? I have no clue how to translate that.

 
gcog

Joined: 2010-05-03
Posts: 12
Posted: Fri, 2010-05-07 09:50

IPTC Author is the photographer
IPTC Redactor is the IPTC tags writer

 
gcog

Joined: 2010-05-03
Posts: 12
Posted: Sun, 2010-05-30 12:20

A new version for the IPTC module is available.

The search function of gallery 3 use the IPTC tags content. (The IPTC tags are added to the search index)
You can choose to set the photo title or photo description from a selected IPTC tag.

Hope this can help,
Gilles.

PS: The module name is iptc not iptc_2 so rename the zip file or the module folder.

 
sproonz

Joined: 2010-05-23
Posts: 11
Posted: Sun, 2010-05-30 13:18

I've downloaded and installed your module. I've activated it (it is identified as "Iptc Data", version 3), but even though I got the message saying it has been activated, I am not prompted to get the data from my images, and there is no IPTC settings in Admin Settings (as explained in http://codex.gallery2.org/Gallery3:Modules:iptc).

 
bratengeier

Joined: 2010-07-23
Posts: 3
Posted: Fri, 2010-07-23 07:54

I have still problems with the german umlaut in this attached image. Maybe you can have a look at it?

And there is another thing: if I upload an image the iptc headline is not taken as title. I allways got the filename. Is this a bug or a feature?

EDIT: Okay, I have to select the title in the administration part - my fault :-(

Thanks for help,
Marc

 
gcog

Joined: 2010-05-03
Posts: 12
Posted: Fri, 2010-07-23 22:13

Marc,

What application/OS are you using to add informations to the image.jpg file ?

Gilles.

 
Geoff Cloake

Joined: 2009-06-24
Posts: 31
Posted: Thu, 2010-08-19 04:53

I am not sure if I am trying to download the right thing - itpc.zip only contains one file called module info - I suspect there should be something else as the module will not install. Thanks for providing plugin - It is what I really what I need and can't wait to use it.

Can you help me please? - Geoff

 
bratengeier

Joined: 2010-07-23
Posts: 3
Posted: Thu, 2010-08-19 11:53

Hi Gilles,

I sorry for my late answer - I thought I would be informed via mail.

I edited the iptc data of the image with irfanview on windows xp. The headline and the caption are read out - but without the german umlaut. I have attached three files with example / screenshot. The strange thing is, that the caption is correctly shown when I read out the exif data.

 
bratengeier

Joined: 2010-07-23
Posts: 3
Posted: Mon, 2010-08-23 19:38

Okay, I fixed it. It is a very small patch:

Replace in the class iptc_core the string row

if (function_exists("mb_detect_encoding") && mb_detect_encoding($value) != "UTF-8") {

with this

if (function_exists("mb_detect_encoding") && mb_detect_encoding($value, "ISO-8859-1, UTF-8") != "UTF-8") {

And everything works perfect!

Marc

 
inposure
inposure's picture

Joined: 2010-04-23
Posts: 304
Posted: Mon, 2010-08-23 19:44

That is not a fix, it will just screw up true Unicode data.

http://sourceforge.net/apps/trac/gallery/ticket/1254

 
tbleher

Joined: 2010-08-26
Posts: 2
Posted: Mon, 2010-08-30 07:29

This module is now in gallery3-contrib on github: http://github.com/gallery/gallery3-contrib/tree/master/modules/iptc/.

Regards,
Thomas

 
Geoff Cloake

Joined: 2009-06-24
Posts: 31
Posted: Tue, 2010-08-31 22:46

Thanks, all files uploaded and 'IPTC Data' lists as a Module but will not install. Tick box clears on 'Update' Any clues?

 
bromide
bromide's picture

Joined: 2010-08-20
Posts: 28
Posted: Wed, 2010-09-01 01:49

Could floridave's problems up above be because he's using something like Windows XP without East Asian Character support installed? Normally I get question marks instead of Unicode characters, though. (Note also: web browsers do their own CJK support so just because you can see Chinese characters in web pages doesn't mean that support module is installed in Windows. You have to try renaming a file to have Chinese characters in the filename or something like that to test it.)
˳® bromide      
                      

 
robjkentjr

Joined: 2010-08-18
Posts: 6
Posted: Thu, 2010-09-23 00:56

Dear gcog,

Just a small issue that I came across.

I use many keywords in my photos entered from Lightroom. When viewed in the IPTC info sidebar, the key words are separated by semicolon only (in Lightroom, there is a comma and space). There is no space after the semicolon to allow the line to break and carry over to the next row. The words run off to the side and a scroll bar comes up. I used the overflow:hidden in the CSS as a temp fix but I would like to roll over the keywords.

Is there a quick way to change this? I looked through the code and did note see an obvious way to fix this.

 
gcog

Joined: 2010-05-03
Posts: 12
Posted: Thu, 2010-09-23 08:14

Dear robjkentjr,

In the code you must change 2 lines (add space after semicolon), the first line for the iptc data and the second line for the xmp data:
- In the file modules/iptc/helpers/iptc.php:57 => $value = implode("; ", $iptc[$iptc_key]);
- In the file modules/iptc/lib/functions.php:92 => $result .= '; ';

After that you must re-extract iptc and xmp data:
Delete all the iptc_records lines in the gallery database or set the dirty flag (UPDATE `iptc_records` set dirty=1)
Run the IPTC task to re extract the tags.

Regards,
Gilles.

 
robjkentjr

Joined: 2010-08-18
Posts: 6
Posted: Thu, 2010-09-23 20:02

Excellent! Thanks so much

 
Geoff Cloake

Joined: 2009-06-24
Posts: 31
Posted: Mon, 2010-12-20 01:25

Do you have any plans to extend your module so that the IPTC data can be added to the database and be included in the Search function? Would it be possible to create dynamic albums based on various IPTC terms. Eg find photos by genre, location, etc.

 
gcog

Joined: 2010-05-03
Posts: 12
Posted: Thu, 2010-12-23 22:50

The IPTC data are already added to the search database.
For dynamic albums, it is out of scope for the IPTC module but it can be a good improvement for the gallery 3

 
xaetva2003

Joined: 2011-01-03
Posts: 1
Posted: Mon, 2011-01-03 11:13

Hello,

Is there a possibility to make IPTC caption and others fields searchable?
I think only IPTC keyword are link to search box?

Thanks

Xa

 
chazzo
chazzo's picture

Joined: 2011-02-02
Posts: 15
Posted: Wed, 2011-02-02 18:22

Gilles, version 2 is working pretty well for me after I added your patch:

gcog wrote:
In the code you must change 2 lines (add space after semicolon), the first line for the iptc data and the second line for the xmp data:
- In the file modules/iptc/helpers/iptc.php:57 => $value = implode("; ", $iptc[$iptc_key]);
- In the file modules/iptc/lib/functions.php:92 => $result .= '; ';

(not tested yet for accents and umlauts). But although IPTC info shows up nicely in the sidebar, it does not seem to be searchable. I updated the search index, but this made no difference. Am I doing something wrong?

--
Gallery 3.0.1, Apache 2.2.3, PHP: 5.2.14, MySQL: 5.1.50, gd

 
gcog

Joined: 2010-05-03
Posts: 12
Posted: Thu, 2011-02-03 09:47

On my gallery I can search on IPTC/XMP infos.
Can you send me a sample image and tell me the info not searchable ?

 
chazzo
chazzo's picture

Joined: 2011-02-02
Posts: 15
Posted: Thu, 2011-02-03 10:45

If you visit this photo in my test gallery:

http://stanhoe.org/gallery/index.php/1950s/Stanhoe_000384

you'll see that the IPTC info is showing OK.

The IPTC Caption is: "Chalk Cottage, now demolished, on the site of the present Butterfly House, 1959", but a search for "Chalk" or "Butterfly" returns no results. As I said before, the search index claims to be up-to-date.

Almost everything in the other IPTC fields has been read into the tags field, so of course searching for these words will work even if the IPTC fields have not been indexed. Only the caption import has failed, which is another story ;-)

Oddly enough, http://stanhoe.org/gallery/index.php/1950s/Stanhoe_000302 has the IPTC Caption "Guy Cross (died 1955)", and a search for "Cross" works, but not "Guy".

Any ideas?

--
Gallery 3.0.1, Apache 2.2.3, PHP: 5.2.14, MySQL: 5.1.50, gd

 
gcog

Joined: 2010-05-03
Posts: 12
Posted: Thu, 2011-02-03 21:32

If you have a problem with small words in the search module, check the variable ft_min_word_len in your mySQL database:
use the SQL 'SHOW VARIABLES' to check the value.
The search module use the full text search capability of mySQL.
http://dev.mysql.com/doc/refman/5.0/en/fulltext-fine-tuning.html

After the modification,
Restart mySQL,
Rebuild the search_records table full text index with:
REPAIR TABLE search_records QUICK;

Hope this help.

 
chazzo
chazzo's picture

Joined: 2011-02-02
Posts: 15
Posted: Thu, 2011-02-03 22:04

Thanks to gcog for his patience in sorting me out. I was using v2 by mistake. v3 works fine and the ability to transfer info from IPTC fields to Gallery's Title and Description fields is magic.

The "short words" search issue could be a real nuisance, so well done for that too.

 
bognerart
bognerart's picture

Joined: 2007-05-05
Posts: 76
Posted: Sat, 2011-04-23 15:34

https://github.com/gallery/gallery3-contrib/tree/master/modules/iptc/ is broken. Is there another place to download it?

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Sat, 2011-04-23 15:52

try https://github.com/gallery/gallery3-contrib/tree/master/3.0/modules/iptc
I fixed the codex page to point to gallerymodules.com as well

Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Tue, 2012-05-01 03:51

gcog
I was going through some tickets and came across:
https://sourceforge.net/apps/trac/gallery/ticket/1836
I just wanted to point it out to you. If you using it you can assign the ticket to yourself and close it or let me know what you want to do.

Dave

_____________________________________________
Blog & G2 || floridave - Gallery Team

 
cchiappa
cchiappa's picture

Joined: 2008-08-11
Posts: 101
Posted: Tue, 2012-05-01 19:25

Oops, I had pinged gcog about this earlier and he had gotten back to me saying that if the code worked he was probably OK with including it. However, improving my php skills enough so that I wasn't just copy and pasting code has been on the back burner while I worked through some other problems with the G3 (I will probably get back to it at some point but if someone else wants to rework the patch that would be great)

 
BillWill

Joined: 2008-08-28
Posts: 205
Posted: Sun, 2012-09-09 18:42

I have been using the Author module to display the photographers name beside each photo until I discovered it broke dynamic albums. I then chose this iptc module to do the same thing. However, it complains that "Your Iptc index needs to be updated. Fix this now."

When I click the "Fix this now" link, it opens a new window Called Extract Iptc data, and within that window it says ORM Validation has failed for items model.

How do I get this one to work?

All I want to do is display the Artist info for each photo. Even if I can get this one to work, it pulls out a lot more info that I really need. Is there a smaller module that will do this?

===========================
Version: 3.0.4 (Ricochet)
Operating system: Linux 2.6.18-194.11.4.el5
Apache/2.2.21
PHP: 5.3.8
MySQL: 5.0.95
Clean Canvas theme
Graphics Toolkit = ImageMagick
Albums: 235
Photos: 75002