Difference between revisions of "ReNamer:Scripts:Exiv2"

From den4b Wiki
Jump to navigation Jump to search
(first version)
(No difference)

Revision as of 17:14, 23 June 2009

Script integrates Exiv2 library in order to extract EXIF/IPTC/XMP tags from many types of images. CRW, CR2, RAW images are also supported.

Requirements

  • ReNamer v5.20 Beta
  • exiv2.exe v0.16 in ReNamer's folder

Code

Author: Denis Kozlov. Date: 10 Mar 2008. Extract unformatted line out of the command line output of the exiv2.exe tool. At the moment, this script extracts image timestamp. Adjust EXIV and TAG constants to extract other tags.

{ Insert EXIF/IPTC/XMP tags from 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]';