Skip to content

Commit

Permalink
Merge pull request #624 from Kicer86/exiftool_replacement
Browse files Browse the repository at this point in the history
Exiftool replacement
  • Loading branch information
Kicer86 authored May 11, 2024
2 parents 664db9a + 7184492 commit a1ad7d9
Show file tree
Hide file tree
Showing 40 changed files with 336 additions and 908 deletions.
2 changes: 1 addition & 1 deletion .github/aur/photobroom-git/PKGBUILD
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ url="https://github.com/Kicer86/photobroom"
license=('GPL3')
groups=()
depends=('exiv2' 'qt6-base' 'qt6-multimedia' 'qt6-declarative' 'qt6-svg' 'qt6-quick3d' 'dlib' 'opencv' 'jsoncpp')
makedepends=('cmake' 'magic_enum' 'qt6-tools' 'imagemagick' 'libwebp' 'cs-libguarded' 'boost' 'openmp')
makedepends=('cmake' 'ffmpeg' 'magic_enum' 'qt6-tools' 'imagemagick' 'libwebp' 'cs-libguarded' 'boost' 'openmp')
optdepends=()
provides=('photobroom')
conflicts=('photobroom')
Expand Down
7 changes: 6 additions & 1 deletion .github/expected_file_list
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ $PLUGINSDIR\System.dll
$PLUGINSDIR\UserInfo.dll
advapi32.dll
animatedwebp.dll
avcodec-60.dll
avformat-60.dll
avutil-58.dll
bcrypt.dll
concrt140.dll
core.dll
cpp_restapi.dll
Expand Down Expand Up @@ -624,11 +628,11 @@ QtQuick\tooling\Signal.qml
QtQuick\Window\qmldir
QtQuick\Window\quickwindowplugin.dll
QtQuick\Window\quickwindow.qmltypes
secur32.dll
shell32.dll
shlwapi.dll
sql_backend_base.dll
system.dll
tools\ExifTool\exiftool.exe
translations\qt_ar.qm
translations\qt_bg.qm
translations\qt_ca.qm
Expand Down Expand Up @@ -661,6 +665,7 @@ translations\qt_zh_TW.qm
tr\photo_broom_en.qm
tr\photo_broom_pl.qm
updater.dll
user32.dll
vcruntime140_1.dll
vcruntime140.dll
ws2_32.dll
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ jobs:
- uses: actions/checkout@v4
with:
submodules: true
lfs: true

- name: Install system dependencies
run: |
Expand Down Expand Up @@ -77,7 +78,7 @@ jobs:
cd exiv2
mkdir build
cd build
cmake ..
cmake .. -DEXIV2_ENABLE_VIDEO=ON -DEXIV2_BUILD_EXIV2_COMMAND=OFF -DEXIV2_BUILD_UNIT_TESTS=OFF -DEXIV2_BUILD_SAMPLES=OFF
cmake --build . --target all
sudo cmake --build . --target install
Expand Down
6 changes: 4 additions & 2 deletions .github/workflows/linux-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ jobs:
- uses: actions/checkout@v4
with:
submodules: true
lfs: true

- name: Install system dependencies
run: |
Expand All @@ -52,6 +53,7 @@ jobs:
libqt6shadertools6-dev \
libqt6svg6-dev \
libqt6quick3druntimerender6 \
libavformat-dev \
libboost-dev \
libopencv-dev \
libdlib-dev \
Expand All @@ -65,7 +67,7 @@ jobs:
if: matrix.compiler.compiler == 'LLVM'
run: |
sudo apt-get install \
clang \
clang
- name: Install magic enum
run: |
Expand All @@ -88,7 +90,7 @@ jobs:
cd exiv2
mkdir build
cd build
cmake ..
cmake .. -DEXIV2_ENABLE_VIDEO=ON -DEXIV2_BUILD_EXIV2_COMMAND=OFF -DEXIV2_BUILD_UNIT_TESTS=OFF -DEXIV2_BUILD_SAMPLES=OFF
cmake --build . --target all
sudo cmake --build . --target install
Expand Down
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,6 @@
[submodule "src/third_party/reflect-cpp"]
path = src/third_party/reflect-cpp
url = https://github.com/getml/reflect-cpp.git
[submodule "src/core/learning_tests/test-videos"]
path = src/core/learning_tests/test-videos
url = https://github.com/Kicer86/VOF-media.git
25 changes: 0 additions & 25 deletions cmake/system/win32.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,6 @@
# http://stackoverflow.com/questions/17446981/cmake-externalproject-add-and-findpackage


function(download_tools)
set(EXIFTOOL_VER 12.77)
if(NOT EXISTS ${CMAKE_CURRENT_BINARY_DIR}/tools/exiftool-${EXIFTOOL_VER}.zip)
message("Downloading ExifTool")
file(DOWNLOAD
https://exiftool.org/exiftool-${EXIFTOOL_VER}.zip ${CMAKE_CURRENT_BINARY_DIR}/tools/exiftool-${EXIFTOOL_VER}.zip
SHOW_PROGRESS
)
file(ARCHIVE_EXTRACT
INPUT ${CMAKE_CURRENT_BINARY_DIR}/tools/exiftool-${EXIFTOOL_VER}.zip
DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/tools
)
endif()

install(FILES ${CMAKE_CURRENT_BINARY_DIR}/tools/exiftool\(-k\).exe
DESTINATION tools/ExifTool/
RENAME exiftool.exe
)

endfunction(download_tools)


function(addDependenciesInstallStep)

find_package(Qt6 REQUIRED COMPONENTS Core)
Expand All @@ -48,9 +26,6 @@ endfunction(addDependenciesInstallStep)
#install dependencies
addDependenciesInstallStep()

#download tools
download_tools()

#uninstall previous version of photo broom
set(CPACK_NSIS_ENABLE_UNINSTALL_BEFORE_INSTALL ON)

Expand Down
2 changes: 2 additions & 0 deletions src/config.hpp.in
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@

#define PHOTO_BROOM_VERSION "@PROJECT_VERSION@"
#define PHOTO_BROOM_SRC_DIR(path) "@PROJECT_SOURCE_DIR@/" path
#define PHOTO_BROOM_BIN_DIR(path) "@PROJECT_BINARY_DIR@/" path
18 changes: 13 additions & 5 deletions src/core/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@

find_package(OpenCV REQUIRED)
find_package(Qt6 REQUIRED COMPONENTS Core Gui Multimedia)
find_package(CsLibGuarded REQUIRED)
find_package(exiv2 REQUIRED)
find_package(FFmpeg COMPONENTS AVCODEC AVFORMAT AVUTIL REQUIRED)
find_package(OpenCV REQUIRED)
find_package(Qt6 REQUIRED COMPONENTS Core Gui)
find_package(Threads REQUIRED)
find_package(CsLibGuarded REQUIRED)

include(GenerateExportHeader)

Expand All @@ -18,10 +19,17 @@ else()
set(EXIV2_LIB exiv2lib)
endif()

# FFmpeg's list of libraries may come with many duplicated entries (with and without absolute paths) which causes
# havoc on Windows. Remove all duplicates and entries which do not come with absolute path
list(REMOVE_DUPLICATES FFMPEG_LIBRARIES)
if(WIN32)
list(FILTER FFMPEG_LIBRARIES INCLUDE REGEX "[a-zA-Z]\\:/")
endif()


set(CORE_SOURCES
implementation/aexif_reader.hpp implementation/aexif_reader.cpp
implementation/configuration_p.hpp
implementation/exiftool_video_details_reader.hpp implementation/exiftool_video_details_reader.cpp
implementation/exiv2_exif_reader.hpp implementation/exiv2_exif_reader.cpp
implementation/hdr_assembler.cpp
implementation/image_media_information.hpp implementation/image_media_information.cpp
Expand Down Expand Up @@ -102,7 +110,7 @@ target_link_libraries(core
PUBLIC
Qt::Core
Qt::Gui
Qt::Multimedia
${FFMPEG_LIBRARIES}
PRIVATE
system
${CMAKE_THREAD_LIBS_INIT}
Expand Down
5 changes: 0 additions & 5 deletions src/core/constants.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,6 @@ namespace ConfigConsts
}


namespace ExternalToolsConfigKeys
{
const char* const exiftoolPath = "tool_path::exiftool";
}

namespace Parameters
{
const QSize databaseThumbnailSize(400, 400);
Expand Down
31 changes: 21 additions & 10 deletions src/core/core_test.cmake
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@

include(${CMAKE_SOURCE_DIR}/cmake/functions.cmake)

find_package(exiv2 REQUIRED)
find_package(FFmpeg COMPONENTS AVCODEC AVFORMAT AVUTIL REQUIRED)
find_package(GTest REQUIRED CONFIG)
find_package(Qt6 REQUIRED COMPONENTS Core Gui)
find_package(Qt6Test REQUIRED)
Expand Down Expand Up @@ -70,19 +72,19 @@ if (BUILD_LEARNING_TESTS)
${hdr_photos_list}
)

add_executable(core_lt_for_opencv
learning_tests/image_aligner_tests.cpp
add_executable(core_lt
learning_tests/hdr_assembler_tests.cpp
learning_tests/image_aligner_tests.cpp
)

target_include_directories(core_lt_for_opencv
target_include_directories(core_lt
PRIVATE
${CMAKE_SOURCE_DIR}/src
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_BINARY_DIR}
)

target_link_libraries(core_lt_for_opencv
target_link_libraries(core_lt
PRIVATE
core

Expand All @@ -94,36 +96,41 @@ if (BUILD_LEARNING_TESTS)
GTest::gmock_main
)

add_dependencies(core_lt_for_opencv
add_dependencies(core_lt
core_tests_images
hdr_photos
)

add_test(
NAME core_learning_tests_for_opencv
COMMAND core_lt_for_opencv
NAME core_learning_tests
COMMAND core_lt
)

set_tests_properties(core_learning_tests_for_opencv PROPERTIES LABELS "LearningTest")
set_tests_properties(core_learning_tests PROPERTIES LABELS "LearningTest")
endif()


add_executable(core_ut
implementation/aexif_reader.cpp
implementation/base_tags.cpp
implementation/exiv2_exif_reader.cpp
implementation/exif_reader_factory.cpp
implementation/data_from_path_extractor.cpp
#implementation/oriented_image.cpp
implementation/exiftool_video_details_reader.cpp
implementation/image_aligner.cpp
implementation/image_media_information.cpp
implementation/media_information.cpp
implementation/media_types.cpp
implementation/model_compositor.cpp
implementation/qmodelindex_selector.cpp
implementation/qmodelindex_comparator.cpp
implementation/video_media_information.cpp
implementation/tag.cpp
implementation/task_executor_utils.cpp
imodel_compositor_data_source.hpp

unit_tests/containers_utils_tests.cpp
unit_tests/data_from_path_extractor_tests.cpp
unit_tests/exiftool_video_details_reader_tests.cpp
unit_tests/function_wrappers_tests.cpp
unit_tests/image_aligner_tests.cpp
unit_tests/json_serializer_tests.cpp
Expand All @@ -134,10 +141,13 @@ add_executable(core_ut
unit_tests/qmodelindex_selector_tests.cpp
unit_tests/status_tests.cpp
unit_tests/tag_value_tests.cpp
unit_tests/video_metadata_extraction_tests.cpp
)

target_link_libraries(core_ut
PRIVATE
${EXIV2_LIB}
${FFMPEG_LIBRARIES}
GTest::gtest
GTest::gmock
GTest::gmock_main
Expand All @@ -153,6 +163,7 @@ target_include_directories(core_ut
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_BINARY_DIR}
${PROJECT_SOURCE_DIR}/src/third_party/reflect-cpp/include
${PROJECT_BINARY_DIR}
)

target_compile_definitions(core_ut
Expand Down
3 changes: 3 additions & 0 deletions src/core/iexif_reader.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ struct CORE_EXPORT IExifReader
Exposure, // float
Projection, // string
ShutterSpeed, // float (seconds)
Xmp_video_DateTimeOriginal, // string
Xmp_video_Width, // int
Xmp_video_Height, // int
};

virtual ~IExifReader() = default;
Expand Down
22 changes: 8 additions & 14 deletions src/core/implementation/aexif_reader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,31 +84,25 @@ std::optional<std::any> AExifReader::get(const QString& path, const IExifReader:
switch(type)
{
case TagType::SequenceNumber:
result = exiv_result(readInt(TagType::SequenceNumber));
break;

case TagType::Orientation:
result = exiv_result(readInt(TagType::Orientation));
case TagType::Xmp_video_Height:
case TagType::Xmp_video_Width:
result = exiv_result(readInt(type));
break;

case TagType::DateTimeOriginal:
result = exiv_result(readString(TagType::DateTimeOriginal));
case TagType::Projection:
case TagType::Xmp_video_DateTimeOriginal:
result = exiv_result(readString(type));
break;

case TagType::PixelXDimension:
result = exiv_result(readLong(TagType::PixelXDimension));
break;

case TagType::PixelYDimension:
result = exiv_result(readLong(TagType::PixelYDimension));
result = exiv_result(readLong(type));
break;

case TagType::Exposure:
result = exiv_result(readRational(TagType::Exposure));
break;

case TagType::Projection:
result = exiv_result(readString(TagType::Projection));
result = exiv_result(readRational(type));
break;

case TagType::ShutterSpeed:
Expand Down
2 changes: 1 addition & 1 deletion src/core/implementation/aexif_reader.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,4 @@ class AExifReader: public IExifReader
std::optional<float> readRational(const TagType &) const;
};

#endif // A_EXIF_READER_HPP
#endif
2 changes: 1 addition & 1 deletion src/core/implementation/exif_reader_factory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ ExifReaderFactory::ExifReaderFactory(): m_feeders()

IExifReader& ExifReaderFactory::get()
{
//ExifTool may not be thread safe. Prepare separate object for each thread
//Exif library may not be thread safe. Prepare separate object for each thread
const auto id = std::this_thread::get_id();
auto it = m_feeders.find(id);

Expand Down
Loading

0 comments on commit a1ad7d9

Please sign in to comment.