ACLOCAL_AMFLAGS = -I m4
SUBDIRS = \
- src \
- lib
+ lib \
+ src
EXTRA_DIST = \
AUTHORS \
GOBJECT_REQUIRED=2.50.0
GTK_REQUIRED=3.24
SQLITE3_REQUIRED=3.40
+EXIV2_REQUIRED=0.28
AC_SUBST(GLIB_REQUIRED)
AC_SUBST(GOBJECT_REQUIRED)
AC_SUBST(GTK_REQUIRED)
AC_SUBST(SQLITE3_REQUIRED)
+AC_SUBST(EXIV2_REQUIRED)
AC_CONFIG_HEADERS(config.h)
AC_PROG_MAKE_SET
AC_PROG_CPP
LT_INIT
+
if test -n "$lt_prog_compiler_pic"; then
CFLAGS="$CFLAGS $lt_prog_compiler_pic"
fi
AC_MSG_CHECKING([whether to build EXIF scanner])
if test x"$HAVE_CXX" = xno; then
AC_MSG_RESULT(no)
- AC_MSG_ERROR("Auto read EXIF cannot be built; missing $dependencies_missing")
+ AC_MSG_WARN("Auto read EXIF cannot be built; missing dependencies")
enable_exif_scanner=no
else
+ LIBS+="-lstdc++"
AC_MSG_RESULT(yes)
fi
AC_SUBST(SQLITE3_LIBS)
AC_SUBST(SQLITE3_CFLAGS)
+PKG_CHECK_MODULES([EXIV2], [exiv2 >= $EXIV2_REQUIRED])
+AC_SUBST(EXIV2_LIBS)
+AC_SUBST(EXIV2_CFLAGS)
+
# Checks for header files.
AC_CHECK_HEADER([assert.h],
AC_DEFINE([HAVE_ASSERT_H], [1], [Define to 1 if you have the <assert.h> header file.]))
AUTOMAKE_OPTIONS = gnu
-IFLAGS = \
+AM_CPPFLAGS = \
-I${top_srcdir} \
- -I${top_builddir}
+ -I${top_builddir} \
+ @EXIV2_CFLAGS@
if BUILD_EXIF_SCANNER
noinst_LIBRARIES = libscanner.a
libscanner_a_SOURCES = \
- main.cpp
+ main.cpp \
+ main.hpp \
+ scanner.h \
+ scanner.cpp
libscanner_a_LIBADD = \
$(LIBOBJS) \
- $(ALLOCA)
+ $(ALLOCA) \
+ @EXIV2_LIBS@
endif
--- /dev/null
+//------------------------------------------------------------------------------
+// File: ExifTool.h
+//
+// Description: C++ library interface to Perl exiftool application script
+//
+// License: Copyright 2013-2019, Phil Harvey (philharvey66 at gmail.com)
+//
+// This is software, in whole or part, is free for use in
+// non-commercial applications, provided that this copyright notice
+// is retained. A licensing fee may be required for use in a
+// commercial application.
+//
+// Created: 2013-11-23 - Phil Harvey
+//------------------------------------------------------------------------------
+#ifndef __EXIFTOOL_H__
+#define __EXIFTOOL_H__
+
+#include "ExifToolPipe.h"
+#include "TagInfo.h"
+
+#define NOW 0
+#define NEVER 1e9
+
+#define SUMMARY_DIRECTORIES_SCANNED "directories scanned"
+#define SUMMARY_DIRECTORIES_CREATED "directories created"
+#define SUMMARY_FILES_FAILED_CONDITION "files failed condition"
+#define SUMMARY_IMAGE_FILES_CREATED "image files created"
+#define SUMMARY_IMAGE_FILES_UPDATED "image files updated"
+#define SUMMARY_IMAGE_FILES_UNCHANGED "image files unchanged"
+#define SUMMARY_IMAGE_FILES_MOVED "image files moved"
+#define SUMMARY_IMAGE_FILES_COPIED "image files copied"
+#define SUMMARY_FILE_UPDATE_ERRORS "files weren't updated due to errors"
+#define SUMMARY_FILE_CREATE_ERRORS "files weren't created due to errors"
+#define SUMMARY_IMAGE_FILES_READ "image files read"
+#define SUMMARY_IMAGE_FILE_ERRORS "files could not be read"
+#define SUMMARY_OUTPUT_FILES_CREATED "output files created"
+#define SUMMARY_OUTPUT_FILES_APPENDED "output files appended"
+#define SUMMARY_HARD_LINKS_CREATED "hard links created"
+#define SUMMARY_HARD_LINK_ERRORS "hard links could not be created"
+#define SUMMARY_SYMBOLIC_LINKS_CREATED "symbolic links created"
+#define SUMMARY_SYMBOLIC_LINK_ERRORS "symbolic links could not be created"
+
+class ExifTool
+{
+public:
+ ExifTool(const char *exec=NULL, const char *arg1=NULL);
+ virtual ~ExifTool();
+
+ TagInfo *ImageInfo(const char *file, const char *opts=NULL, double timeout=NEVER);
+
+ int ExtractInfo(const char *file, const char *opts=NULL);
+ TagInfo *GetInfo(int cmdNum=0, double timeout=NEVER);
+
+ int SetNewValue(const char *tag=NULL, const char *value=NULL, int len=-1);
+ int WriteInfo(const char *file, const char *opts=NULL, TagInfo *info=NULL);
+
+ int Command(const char *cmd=NULL);
+ int Complete(double timeout=NEVER);
+
+ int IsRunning();
+ int LastComplete() { return mLastComplete; }
+ int LastCommand() { return mCmdNum; } // (undocumented)
+ void SetLastComplete(int lastComplete) { mLastComplete = lastComplete; }
+ void SetWaitTime(int waitTime) { mWaitTime = waitTime; }
+
+ char * GetOutput() { return mLastComplete > 0 ? mStdout.GetString() : NULL; }
+ int GetOutputLen() { return mLastComplete > 0 ? mStdout.GetStringLen() : 0; }
+ char * GetError() { return mLastComplete > 0 ? mStderr.GetString() : NULL; }
+ int GetErrorLen() { return mLastComplete > 0 ? mStderr.GetStringLen() : 0; } // (undocumented)
+
+ int GetSummary(const char *msg);
+
+ // flags to allow some ExifTool features to be disabled
+ // (must be set before creating ExifTool object)
+ static int sNoSigPipe; // set to disable SIGPIPE handler
+ static int sNoWatchdog; // set to disable watchdog process
+
+private:
+ ExifToolPipe mStdout; // buffer for exiftool stdout read pipe
+ ExifToolPipe mStderr; // buffer for exiftool stderr read pipe
+ int mTo; // write pipe for exiftool stdin
+ int mPid; // exiftool application process ID
+ int mWatchdog; // watchdog process ID
+ TagInfo * mWriteInfo; // tag information to write
+ char * mCmdQueue; // queued command arguments (NULL if nothing queued)
+ int mCmdQueueLen; // length of data in command queue
+ int mCmdQueueSize;// size of command queue
+ int mLastComplete;// result of last Complete() call
+ int mCmdNum; // last command number
+ int mWaitTime; // time to wait (microsec) if no commands in queue
+};
+
+#endif // __EXIFTOOL_H__
--- /dev/null
+//------------------------------------------------------------------------------
+// File: ExifToolPipe.h
+//
+// Description: Piped output from exiftool application
+//
+// License: Copyright 2013-2019, Phil Harvey (philharvey66 at gmail.com)
+//
+// This is software, in whole or part, is free for use in
+// non-commercial applications, provided that this copyright notice
+// is retained. A licensing fee may be required for use in a
+// commercial application.
+//
+// Created: 2013-11-23 - Phil Harvey
+//------------------------------------------------------------------------------
+#ifndef __EXIFTOOLPIPE_H__
+#define __EXIFTOOLPIPE_H__
+
+class ExifToolPipe
+{
+public:
+ ExifToolPipe();
+ ~ExifToolPipe();
+ void Init(int fd, int pid, int initialSize);
+ int Read(); // read exiftool response
+ void Free(); // free buffer memory
+ void Flush(); // remove previous response from buffer
+ char * GetString() { return (mString && mString[0]) ? mString : (char *)0; }
+ int GetStringLen() { return mStringLen; }
+
+private:
+ int mFile; // read file descriptor
+ char * mBuff; // buffer pointer
+ int mSize; // buffer size
+ int mLen; // length of data in buffer
+ int mPos; // current read position in buffer
+ int mSearchPos; // current search position in buffer
+ int mBlockSize; // initial buffer size
+ char * mString; // returned string from last Read()
+ int mStringLen; // length of returned string
+ int mPid; // process id for other side of the pipe
+};
+
+#endif // __EXIFTOOLPIPE_H__
--- /dev/null
+//------------------------------------------------------------------------------
+// File: TagInfo.h
+//
+// Description: Tag information object
+//
+// License: Copyright 2013-2019, Phil Harvey (philharvey66 at gmail.com)
+//
+// This is software, in whole or part, is free for use in
+// non-commercial applications, provided that this copyright notice
+// is retained. A licensing fee may be required for use in a
+// commercial application.
+//
+// Created: 2013-11-23 - Phil Harvey
+//------------------------------------------------------------------------------
+#ifndef __TAGINFO_H__
+#define __TAGINFO_H__
+
+struct TagInfo
+{
+ TagInfo();
+ virtual ~TagInfo();
+
+ char *group[3]; // family 0-2 group names
+ char *name; // tag name
+ char *desc; // tag description
+ char *id; // tag ID
+ char *value; // converted value
+ int valueLen; // length of value in bytes (not including null terminator)
+ char *num; // "numerical" value
+ int numLen; // length of numerical value
+ int copyNum; // copy number for this tag name
+ TagInfo *next; // next TagInfo in linked list
+};
+
+#endif // __TAGINFO_H__
- int main(int argc, char** argv) {
- return 0;
- }
+#include "main.hpp"
+
+using namespace std;
+
+
+ExifScanner::ExifScanner(const char* file): file(file) {
+
+}
+
+ExifScanner::~ExifScanner() {
+
+}
+
+void ExifScanner::scanner_do_work() {
+ if (file == NULL){
+ cout << "Example1: Read metadata from an image." << endl;
+ cout << "Please specify input file name" << endl;
+ return;
+ }
+
+ // create our ExifTool object
+ ExifTool *et = new ExifTool();
+ // read metadata from the image
+ TagInfo *info = et->ImageInfo(file);
+ if (info) {
+ // print returned information
+ for (TagInfo *i=info; i; i=i->next) {
+ cout << i->name << " = " << i->value << endl;
+ }
+ // we are responsible for deleting the information when done
+ delete info;
+ } else if (et->LastComplete() <= 0) {
+ cerr << "Error executing exiftool!" << endl;
+ }
+ // print exiftool stderr messages
+ char *err = et->GetError();
+ if (err) cout << err;
+ delete et; // delete our ExifTool object
+}
--- /dev/null
+/*
+ * main.hpp
+ *
+ * Copyright 2024 Michael Rasmussen <mir@datanom.net>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ *
+ *
+ */
+
+
+#ifndef _MAIN_HPP_
+#define _MAIN_HPP_
+
+#include <iostream>
+#include "exiftool/ExifTool.h"
+
+class ExifScanner {
+public:
+ ExifScanner(const char* file);
+ ~ExifScanner();
+
+ void scanner_do_work();
+
+private:
+ const char* file;
+
+};
+
+#endif /* _MAIN_HPP_ */
--- /dev/null
+/*
+ * scanner.cpp
+ *
+ * Copyright 2024 Michael Rasmussen <mir@datanom.net>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ *
+ *
+ */
+
+#include <stdlib.h>
+#include "main.hpp"
+#include "scanner.h"
+
+struct Scanner {
+ void* obj;
+};
+
+Scanner_t* scanner_create(const char* file) {
+ Scanner_t* s;
+ ExifScanner* obj;
+
+ s = (typeof(s))malloc(sizeof(*s));
+ obj = new ExifScanner(file);
+ s->obj = obj;
+
+ return s;
+}
+
+void scanner_destroy(Scanner_t* s) {
+ if (s == NULL)
+ return;
+
+ delete static_cast<ExifScanner *>(s->obj);
+ free(s);
+}
+
+void scanner_do_work(Scanner_t* s) {
+ ExifScanner* obj;
+
+ if (s == NULL)
+ return;
+
+ obj = static_cast<ExifScanner *>(s->obj);
+ obj->scanner_do_work();
+}
--- /dev/null
+/*
+ * scanner.h
+ *
+ * Copyright 2024 Michael Rasmussen <mir@datanom.net>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ *
+ *
+ */
+
+#ifndef _SCANNER_H_
+#define _SCANNER_H_
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+struct Scanner;
+typedef struct Scanner Scanner_t;
+
+Scanner_t* scanner_create(const char* file);
+
+void scanner_destroy(Scanner_t* s);
+
+void scanner_do_work(Scanner_t* s);
+
+#ifdef __cplusplus
+}
+#endif
+
+
+#endif /* _SCANNER_H_ */
AUTOMAKE_OPTIONS = gnu
+extra =
+
+if BUILD_EXIF_SCANNER
+extra += \
+ ${top_builddir}/lib/libscanner.a \
+ ${top_builddir}/lib/exiftool/exiftool.a
+endif
+
AM_CPPFLAGS = \
-I${top_srcdir} \
-I${top_builddir} \
+ -I${top_srcdir}/lib \
@GLIB_CFLAGS@ \
@GTK_CFLAGS@ \
@SQLITE3_CFLAGS@
lensdb_LDADD = \
@GLIB_LIBS@ \
@GTK_LIBS@ \
- @SQLITE3_LIBS@
+ @SQLITE3_LIBS@ \
+ ${extra} \
+ @LIBS@
+
lensdb_LDFLAGS =
#include <stdio.h>
#include "sqlite-storage.h"
#include "gui.h"
-
+#include "lib/scanner.h"
gint main(gint argc, gchar** argv) {
gint status = 0;
+// Scanner_t* sc = scanner_create("/home/mir/Pictures/Pictures/20211019_0012.jpg");
+// Scanner_t* sc = scanner_create("/home/mir/Pictures/Pictures/2024/09/14/Lndskrona Foto Festival/Lndskrona Foto Festival-8.ORF");
+ Scanner_t* sc = scanner_create("/home/mir/Pictures/Pictures/2024/08/21/Fototur til Hejresøen/Fototur til Hejresøen-6.NEF");
+ scanner_do_work(sc);
+ scanner_destroy(sc);
+
gchar* path = g_path_get_dirname(argv[0]);
if ((status = init_storage(path)) > 0) {
fprintf(stderr, "%s: Failed to open DB\n", path);