Posted on 2009-12-26 23:02:01-08 by barbalex
how to mass write iptc-info from database into jpg-files
Hi

I have 12'000 jpg-files in a folder. A database contains information on every file (description, categories) that I want to write into iptc-fields. The database also includes the filename and -path.

I could prepare a file in any needed format.

But how can I mass write the data for all files in a single process?

Thanks in advance for ideas.

Alex
Direct Responses: 12021 | Write a response
Posted on 2009-12-27 12:18:00-08 by exiftool in response to 12017
Re: how to mass write iptc-info from database into jpg-files
Hi Alex,

This can be done with a bit of custom scripting. You should be able to find a couple of examples by searching this forum, and here's the first one I found with a quick search:

http://www.cpanforum.com/threads/11196

- Phil
Direct Responses: 12024 | 12153 | Write a response
Posted on 2009-12-27 14:08:24-08 by barbalex in response to 12021
Re: how to mass write iptc-info from database into jpg-files
Hi Phil

Wow, that looks exactly like it could solve my problem. O.k., let's go for mission impossible...

Thanks a lot!

Alex
Direct Responses: Write a response
Posted on 2010-01-10 00:38:15-08 by barbalex in response to 12021
Re: how to mass write iptc-info from database into jpg-files
Hi Phil

I can't seem to get the Syntax for the file "write_from_txt" right.

I have tried things like:
======== C:/test/0001.JPG
XPSubject : Thema
or
======== C:/test/0001.JPG
ImageDescription, TitelImageDescriptionNeu
or
======== C:/test/0001.JPG
[ImageDescription] TitelImageDescriptionNeu
or
[========] C:/test/0001.JPG
[ImageDescription] TitelImageDescriptionNeu

I always get the message: "write_from_txt TXTFILE [TAGS]", then the script dies.
What does the file have to look like?

Alex
Direct Responses: 12155 | Write a response
Posted on 2010-01-10 11:23:53-08 by exiftool in response to 12153
Re: how to mass write iptc-info from database into jpg-files
Hi Alex,

I think your first syntax is correct. You will get the message you mentioned (well, actually "SYNTAX: write_from_txt INFILE [TAGS]") if you don't put the name of the file on the command line. ie)

write_from_text file.txt

Where "file.txt" is the name of your txt file. (This is what the message is trying to tell you.)

- Phil
Direct Responses: 12156 | Write a response
Posted on 2010-01-10 19:56:10-08 by barbalex in response to 12155
Re: how to mass write iptc-info from database into jpg-files
Hi Phil

Thank you a lot, I am one step further now. Unfortunately only one :-(
Now I get this message: Error opening 'write_from_txt'

I am still not quite sure how to write the command line. To try this out I have made a simple 'write_from_txt'-File. It contains:
======== C:/test/0001.JPG
ImageDescription: TitelImageDescriptionNeu

My script is named 1.pl

Does the command line go like this:
1.pl write_from_txt write.txt [ImageDescription]
or
1.pl write_from_txt write.txt [ImageDescription]\n
or
1.pl write_from_txt write.txt "ImageDescription"
or
1.pl write_from_txt "write.txt" [ImageDescription]

I have tried all sorts of combinations - nothing worked.
And what would it be with several Tags? Would the tagnames all be written inside the brackets, separated by commas?

Alex
Direct Responses: 12159 | Write a response
Posted on 2010-01-11 12:34:56-08 by exiftool in response to 12156
Re: how to mass write iptc-info from database into jpg-files
Hi Alex,

There appears to be some confusion. In my examples, "write_from_txt" is the name of the perl script that you are calling "1.pl". So your command line should be:

1.pl write.txt ImageDescription

(The square brackets in the syntax idicate optional arguments. Additional tag names should be separated by a space.)

- Phil
Direct Responses: 12162 | 12167 | 12168 | 12169 | Write a response
Posted on 2010-01-11 23:24:37-08 by barbalex in response to 12159
Re: how to mass write iptc-info from database into jpg-files
Wow, that did it. Mission impossible completed. You made my day!

Thanks so much, Phil
Direct Responses: Write a response
Posted on 2010-01-12 11:20:55-08 by barbalex in response to 12159
Re: how to mass write iptc-info from database into jpg-files
Hi Phil

Writing the Tags works for all 6000 files with:
1.pl ObjectName.txt ObjectName

Only problem: I get this message: Warning = Malformed UTF-8 character(s) because I use ae, oe, ue etc.

I tried the following inputs:
1.pl ObjectName.txt ObjectName
1.pl ObjectName.txt ObjectName -charset iptc=CHARSET
1.pl ObjectName.txt ObjectName -charset UTF8
1.pl ObjectName.txt ObjectName -charset=UTF8
1.pl ObjectName.txt ObjectName -codedcharacterset=utf8


How can I get correct coding?

Alex
Direct Responses: Write a response
Posted on 2010-01-12 11:42:43-08 by barbalex in response to 12159
Re: how to mass write iptc-info from database into jpg-files
Hi Phil

How can I add a new Value without replacing the existing one?

In my script, this would probably be where et says:
$exifTool->SetNewValue($tag, $val);
I want to add iptc Keywords.

Would it be something with
-TAG+=VALUE
or is there a different call, like AddNewValue?

Alex
Direct Responses: Write a response
Posted on 2010-01-12 11:53:23-08 by barbalex in response to 12159
Re: how to mass write iptc-info from database into jpg-files
Hi Phil

Writing the Tags works for all 6000 files with:
1.pl ObjectName.txt ObjectName

Only problem: I get this message: Warning = Malformed UTF-8 character(s) because I use ae, oe, ue etc.

I tried the following inputs:
1.pl ObjectName.txt ObjectName
1.pl ObjectName.txt ObjectName -charset iptc=CHARSET
1.pl ObjectName.txt ObjectName -charset UTF8
1.pl ObjectName.txt ObjectName -charset=UTF8
1.pl ObjectName.txt ObjectName -codedcharacterset=utf8


How can I get correct coding?

Alex
Direct Responses: 12172 | Write a response
Posted on 2010-01-12 12:25:39-08 by exiftool in response to 12169
Re: how to mass write iptc-info from database into jpg-files
Hi Alex,

What encoding did you use for the text in "ObjectName.txt"?

It is best if you can use UTF-8 for this file. Otherwise, you must use the -charset option to specify the encoding that you did use. If you are in Windows, my guess is that -charset Latin may get you going. The warning you are getting is because exiftool assumes the input to be UTF-8 by default, but apparently it isn't valid UTF-8.

To add to a list item, you use

$exifTool->SetNewValue($tag, $val, AddValue => 1);
Direct Responses: 12183 | Write a response
Posted on 2010-01-12 12:49:18.509775-08 by barbalex in response to 12172
Re: how to mass write iptc-info from database into jpg-files
Hi Phil

AddValue => 1 works perfectly, that's great. Thanks for your help!

Encoding seems to have been ANSI. I set it now to UTF8 (using once the Windows Editor and once jEdit).
But -charset Latin1, -charset Latin2, -charset Latin, -charset UTF8 or setting no -charset don't wo +rk. Same Message.

I also tried setting the encoding to Latin and using -charset Latin. Did not work either.

I work on Windows7.

Alex
Direct Responses: 12186 | Write a response
Posted on 2010-01-12 16:31:23.769594-08 by exiftool in response to 12183
Re: how to mass write iptc-info from database into jpg-files
Hi Alex,

If you email me all the files I need to reproduce what you are doing I should be able to figure out what is going on. My mail is phil at owl.phy.queensu.ca

- Phil
Direct Responses: Write a response
Perl Weekly newsletter
A free weekly newsletter for people who are busy to read all the blogs. click here to check it out.