#1 2008-01-19 16:31

Wlk
Member
Registered: 2008-01-19
Posts: 1

IPTC/XMP tag support

Is there any chance that these sorts of tags will be added? I use them a lot in my pictures and renaming according to them would be sweet :-)

Thanx!

Offline

#2 2008-01-20 23:53

den4b
Administrator
From: den4b.com
Registered: 2006-04-06
Posts: 3,367

Re: IPTC/XMP tag support

Unfortunately, there is no chance of adding support for these tags. There is not free / open source libraries for Delphi which would let me read these tags from images, and implementing it from the scratch could take months. I don't have time for massive tasks like that.

BUT, there is a possibility of using Exiv2 tool in combination with ReNamer to extract IPTC data, like it was done for extracting date/time from RAW images. Have a look at this topic, it explains everything: Date and Time from RAW images (CRW, CR2, RAW).

It should work with slight modification. Tell us if you have any problems.

Offline

#3 2008-03-10 13:29

den4b
Administrator
From: den4b.com
Registered: 2006-04-06
Posts: 3,367

Re: IPTC/XMP tag support

Exiv2 tool has to be downloaded and extracted into ReNamer's folder: http://www.exiv2.org/. You will also need the latest development version of ReNamer, or the next release after the date of this post. Below is the code which will put into the filename ANY of the tags which can be read by Exiv2 tool, just modify the TAG and EXIV values to suit the tags which you want to use.

{ Insert EXIF/IPTC/XMP tags from any images }

const
  EXIV = '"exiv2.exe"';
  TAG = 'Image timestamp\s*\:\s*(.*?)[\r\n]';
  
var
  Command, Output: String;
  Matches: TStringsArray;  

begin
  Command := EXIV+' "'+FilePath+'"';
  if ExecConsoleApp(Command, Output) = 0 then
  begin
    Matches := SubMatchesRegEx(Output, TAG, False);
    if Length(Matches) > 0 then
      FileName := Matches[0] + WideExtractFileExt(FileName);
  end;
end.

For example, to extract IPTC Headline tag, you would need to make following changes:

EXIV = '"exiv2.exe" -pi';
TAG = 'Iptc.Application2.Headline\s*\w*\s*\d*\s*(.*?)[\r\n]';

NOTE: This script worked for ReNamer v5.20+ Beta and Exiv2 v0.16.

Offline

#4 2015-11-25 10:19

nico71it
Member
Registered: 2015-11-25
Posts: 2

Re: IPTC/XMP tag support

In case it will help someone, I've modified the script to have a valid file name constructed using the EXIF data information:

const
  EXIV = '"exiv2.exe"';
  TAG = 'Image timestamp\s*\:\s*(.*?)[\r\n]';

var
  Command, Output: String;
  Matches, DateEXIF: TStringsArray;

begin
  Command := EXIV+' "'+FilePath+'"';
  if ExecConsoleApp(Command, Output) = 0 then
  begin
    Matches := SubMatchesRegEx(Output, TAG, False);
    DateEXIF := SubMatchesRegEx(Matches[0], '(.+)\:(.+)\:(.+)\ (.+)\:(.+)\:(.+)', False);
    if Length(DateEXIF) > 0 then
      FileName := DateEXIF[0] + '-' + DateEXIF[1] + '-' + DateEXIF[2] + ' ' +
                  DateEXIF[3] + '.' + DateEXIF[4] + '.' + DateEXIF[5] +
                  WideExtractFileExt(FileName);
  end;
end.

Last edited by den4b (2015-11-25 12:39)

Offline

#5 2015-11-25 14:47

den4b
Administrator
From: den4b.com
Registered: 2006-04-06
Posts: 3,367

Re: IPTC/XMP tag support

Good work nico71it.

In your code, make sure you check that "Matches[0]" exists before accessing it.

Also, have a look at Exiv scripts on Wiki for a version with user customizable date format.

Offline

#6 2015-11-25 17:31

nico71it
Member
Registered: 2015-11-25
Posts: 2

Re: IPTC/XMP tag support

You're right! I've noticed it after posting :-)
I'll fix it ASAP

Offline

Board footer

Powered by FluxBB