ExifTool.h
Go to the documentation of this file.
1 // SPDX-License-Identifier: LicenseRef-ExiftoolCpp
2 // SPDX-FileCopyrightText: Copyright 2013-2019, Phil Harvey (philharvey66 at gmail.com)
3 
4 //------------------------------------------------------------------------------
5 // File: ExifTool.h
6 //
7 // Description: C++ library interface to Perl exiftool application script
8 //
9 // License: Copyright 2013-2019, Phil Harvey (philharvey66 at gmail.com)
10 //
11 // This is software, in whole or part, is free for use in
12 // non-commercial applications, provided that this copyright notice
13 // is retained. A licensing fee may be required for use in a
14 // commercial application.
15 //
16 // Created: 2013-11-23 - Phil Harvey
17 //------------------------------------------------------------------------------
18 #ifndef __EXIFTOOL_H__
19 #define __EXIFTOOL_H__
20 
21 #include "ExifToolPipe.h"
22 #include "TagInfo.h"
23 
24 #define NOW 0
25 #define NEVER 1e9
26 
27 #define SUMMARY_DIRECTORIES_SCANNED "directories scanned"
28 #define SUMMARY_DIRECTORIES_CREATED "directories created"
29 #define SUMMARY_FILES_FAILED_CONDITION "files failed condition"
30 #define SUMMARY_IMAGE_FILES_CREATED "image files created"
31 #define SUMMARY_IMAGE_FILES_UPDATED "image files updated"
32 #define SUMMARY_IMAGE_FILES_UNCHANGED "image files unchanged"
33 #define SUMMARY_IMAGE_FILES_MOVED "image files moved"
34 #define SUMMARY_IMAGE_FILES_COPIED "image files copied"
35 #define SUMMARY_FILE_UPDATE_ERRORS "files weren't updated due to errors"
36 #define SUMMARY_FILE_CREATE_ERRORS "files weren't created due to errors"
37 #define SUMMARY_IMAGE_FILES_READ "image files read"
38 #define SUMMARY_IMAGE_FILE_ERRORS "files could not be read"
39 #define SUMMARY_OUTPUT_FILES_CREATED "output files created"
40 #define SUMMARY_OUTPUT_FILES_APPENDED "output files appended"
41 #define SUMMARY_HARD_LINKS_CREATED "hard links created"
42 #define SUMMARY_HARD_LINK_ERRORS "hard links could not be created"
43 #define SUMMARY_SYMBOLIC_LINKS_CREATED "symbolic links created"
44 #define SUMMARY_SYMBOLIC_LINK_ERRORS "symbolic links could not be created"
45 
46 class ExifTool
47 {
48 public:
49  ExifTool(const char *exec=NULL, const char *arg1=NULL);
50  virtual ~ExifTool();
51 
52  TagInfo *ImageInfo(const char *file, const char *opts=NULL, double timeout=NEVER);
53 
54  int ExtractInfo(const char *file, const char *opts=NULL);
55  TagInfo *GetInfo(int cmdNum=0, double timeout=NEVER);
56 
57  int SetNewValue(const char *tag=NULL, const char *value=NULL, int len=-1);
58  int WriteInfo(const char *file, const char *opts=NULL, TagInfo *info=NULL);
59 
60  int Command(const char *cmd=NULL);
61  int Complete(double timeout=NEVER);
62 
63  int IsRunning();
64  int LastComplete() { return mLastComplete; }
65  int LastCommand() { return mCmdNum; } // (undocumented)
66  void SetLastComplete(int lastComplete) { mLastComplete = lastComplete; }
67  void SetWaitTime(int waitTime) { mWaitTime = waitTime; }
68 
69  char * GetOutput() { return mLastComplete > 0 ? mStdout.GetString() : NULL; }
70  int GetOutputLen() { return mLastComplete > 0 ? mStdout.GetStringLen() : 0; }
71  char * GetError() { return mLastComplete > 0 ? mStderr.GetString() : NULL; }
72  int GetErrorLen() { return mLastComplete > 0 ? mStderr.GetStringLen() : 0; } // (undocumented)
73 
74  int GetSummary(const char *msg);
75 
76  // flags to allow some ExifTool features to be disabled
77  // (must be set before creating ExifTool object)
78  static int sNoSigPipe; // set to disable SIGPIPE handler
79  static int sNoWatchdog; // set to disable watchdog process
80 
81 private:
82  ExifToolPipe mStdout; // buffer for exiftool stdout read pipe
83  ExifToolPipe mStderr; // buffer for exiftool stderr read pipe
84  int mTo; // write pipe for exiftool stdin
85  int mPid; // exiftool application process ID
86  int mWatchdog; // watchdog process ID
87  TagInfo * mWriteInfo; // tag information to write
88  char * mCmdQueue; // queued command arguments (NULL if nothing queued)
89  int mCmdQueueLen; // length of data in command queue
90  int mCmdQueueSize;// size of command queue
91  int mLastComplete;// result of last Complete() call
92  int mCmdNum; // last command number
93  int mWaitTime; // time to wait (microsec) if no commands in queue
94 };
95 
96 #endif // __EXIFTOOL_H__
ExifToolPipe::GetStringLen
int GetStringLen()
Definition: ExifToolPipe.h:31
ExifTool::sNoSigPipe
static int sNoSigPipe
Definition: ExifTool.h:78
ExifTool::WriteInfo
int WriteInfo(const char *file, const char *opts=NULL, TagInfo *info=NULL)
ExifTool::mCmdQueueLen
int mCmdQueueLen
Definition: ExifTool.h:89
ExifTool::LastComplete
int LastComplete()
Definition: ExifTool.h:64
ExifTool::GetErrorLen
int GetErrorLen()
Definition: ExifTool.h:72
ExifTool::LastCommand
int LastCommand()
Definition: ExifTool.h:65
ExifTool::mCmdNum
int mCmdNum
Definition: ExifTool.h:92
ExifTool::GetOutput
char * GetOutput()
Definition: ExifTool.h:69
ExifToolPipe
Definition: ExifToolPipe.h:21
value
GeneratorWrapper< T > value(T &&value)
ExifTool::Complete
int Complete(double timeout=NEVER)
ExifTool::GetSummary
int GetSummary(const char *msg)
ExifTool::mTo
int mTo
Definition: ExifTool.h:84
TagInfo
Definition: TagInfo.h:21
ExifTool::mCmdQueueSize
int mCmdQueueSize
Definition: ExifTool.h:90
ExifTool::SetNewValue
int SetNewValue(const char *tag=NULL, const char *value=NULL, int len=-1)
ExifTool::sNoWatchdog
static int sNoWatchdog
Definition: ExifTool.h:79
ExifToolPipe::GetString
char * GetString()
Definition: ExifToolPipe.h:30
ExifTool::ImageInfo
TagInfo * ImageInfo(const char *file, const char *opts=NULL, double timeout=NEVER)
ExifTool::mLastComplete
int mLastComplete
Definition: ExifTool.h:91
ExifToolPipe.h
ExifTool::mStdout
ExifToolPipe mStdout
Definition: ExifTool.h:82
ExifTool::mWaitTime
int mWaitTime
Definition: ExifTool.h:93
ExifTool::IsRunning
int IsRunning()
ExifTool::SetLastComplete
void SetLastComplete(int lastComplete)
Definition: ExifTool.h:66
ExifTool::ExifTool
ExifTool(const char *exec=NULL, const char *arg1=NULL)
ExifTool
Definition: ExifTool.h:46
ExifTool::mWriteInfo
TagInfo * mWriteInfo
Definition: ExifTool.h:87
ExifTool::ExtractInfo
int ExtractInfo(const char *file, const char *opts=NULL)
ExifTool::Command
int Command(const char *cmd=NULL)
TagInfo.h
ExifTool::GetInfo
TagInfo * GetInfo(int cmdNum=0, double timeout=NEVER)
ExifTool::mCmdQueue
char * mCmdQueue
Definition: ExifTool.h:88
NEVER
#define NEVER
Definition: ExifTool.h:25
ExifTool::mWatchdog
int mWatchdog
Definition: ExifTool.h:86
ExifTool::GetOutputLen
int GetOutputLen()
Definition: ExifTool.h:70
ExifTool::mStderr
ExifToolPipe mStderr
Definition: ExifTool.h:83
ExifTool::~ExifTool
virtual ~ExifTool()
ExifTool::GetError
char * GetError()
Definition: ExifTool.h:71
ExifTool::SetWaitTime
void SetWaitTime(int waitTime)
Definition: ExifTool.h:67
cmd
string cmd
ExifTool::mPid
int mPid
Definition: ExifTool.h:85


exiftool_metadata_extractor
Author(s): Martin Pecka
autogenerated on Wed May 28 2025 02:07:28