Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Xmp toolkit v2023-12 submodule #3014

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/nightly_Linux_distributions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ jobs:

steps:
- uses: actions/checkout@v4
with:
submodules: true
- name: Install dependencies
run: ./ci/install_dependencies.sh
- name: Build and install
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/on_PR_linux_matrix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ jobs:

steps:
- uses: actions/checkout@v4
with:
submodules: true

- name: Install dependencies
run: |
Expand Down
9 changes: 9 additions & 0 deletions .github/workflows/on_PR_linux_special_builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ jobs:
steps:
- uses: actions/checkout@v4
with:
submodules: true
fetch-depth: 2
# Trying to deal with warning: -> Issue detecting commit SHA. Please run actions/checkout with fetch-depth > 1 or set to 0

Expand Down Expand Up @@ -65,6 +66,8 @@ jobs:

steps:
- uses: actions/checkout@v4
with:
submodules: true

- name: Install dependencies
run: |
Expand Down Expand Up @@ -100,6 +103,8 @@ jobs:

steps:
- uses: actions/checkout@v4
with:
submodules: true

- name: Install dependencies
run: |
Expand Down Expand Up @@ -134,6 +139,8 @@ jobs:

steps:
- uses: actions/checkout@v4
with:
submodules: true

- name: Install dependencies
run: |
Expand All @@ -156,6 +163,8 @@ jobs:

steps:
- uses: actions/checkout@v4
with:
submodules: true

- name: Install dependencies
run: |
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/on_PR_linux_staticAnalysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ jobs:
steps:
- uses: actions/checkout@v4
with:
submodules: true
fetch-depth: 2
# Trying to deal with warning: -> Issue detecting commit SHA. Please run actions/checkout with fetch-depth > 1 or set to 0

Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/on_PR_mac_matrix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ jobs:

steps:
- uses: actions/checkout@v4
with:
submodules: true

- name: Install dependencies
run: |
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/on_PR_mac_special_builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ jobs:

steps:
- uses: actions/checkout@v4
with:
submodules: true

- name: Install dependencies
run: |
Expand Down
16 changes: 16 additions & 0 deletions .github/workflows/on_PR_meson.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ jobs:
deps: ['forcefallback', 'default']
steps:
- uses: actions/checkout@v4
with:
submodules: true
- uses: egor-tensin/setup-gcc@v1
with:
version: ${{matrix.cxx}}
Expand All @@ -35,6 +37,8 @@ jobs:
deps: ['forcefallback', 'default']
steps:
- uses: actions/checkout@v4
with:
submodules: true
- uses: egor-tensin/setup-clang@v1
with:
version: ${{matrix.cxx}}
Expand All @@ -58,6 +62,8 @@ jobs:
platform: ['x64', 'x86']
steps:
- uses: actions/checkout@v4
with:
submodules: true

- name: Install packages
run: |
Expand All @@ -80,6 +86,8 @@ jobs:
deps: ['forcefallback', 'default']
steps:
- uses: actions/checkout@v4
with:
submodules: true

- name: Install packages
run: |
Expand Down Expand Up @@ -107,6 +115,8 @@ jobs:
shell: msys2 {0}
steps:
- uses: actions/checkout@v4
with:
submodules: true

- uses: msys2/setup-msys2@v2
with:
Expand Down Expand Up @@ -134,6 +144,8 @@ jobs:
deps: ['enabled', 'disabled']
steps:
- uses: actions/checkout@v4
with:
submodules: true

- name: Install packages
run: |
Expand All @@ -148,6 +160,8 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: true
- uses: vmactions/freebsd-vm@v1
with:
prepare: |
Expand All @@ -160,6 +174,8 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: true
- name: Install packages
run: |
python3 -m pip install meson ninja
Expand Down
6 changes: 6 additions & 0 deletions .github/workflows/on_PR_windows_matrix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ jobs:

steps:
- uses: actions/checkout@v4
with:
submodules: true

- name: Set up Visual Studio shell
uses: ilammy/msvc-dev-cmd@v1
Expand Down Expand Up @@ -94,6 +96,8 @@ jobs:

steps:
- uses: actions/checkout@v4
with:
submodules: true

- name: Set up MSYS2
uses: msys2/setup-msys2@v2
Expand Down Expand Up @@ -150,6 +154,8 @@ jobs:
- run: git config --global core.autocrlf input
shell: pwsh
- uses: actions/checkout@v4
with:
submodules: true

- name: Set up Cygwin
uses: cygwin/cygwin-install-action@v4
Expand Down
6 changes: 6 additions & 0 deletions .github/workflows/on_push_BasicWinLinMac.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ jobs:

steps:
- uses: actions/checkout@v4
with:
submodules: true

- name: Set up Visual Studio shell
uses: ilammy/msvc-dev-cmd@v1
Expand Down Expand Up @@ -57,6 +59,8 @@ jobs:

steps:
- uses: actions/checkout@v4
with:
submodules: true

- name: Install dependencies
run: |
Expand Down Expand Up @@ -91,6 +95,8 @@ jobs:

steps:
- uses: actions/checkout@v4
with:
submodules: true

- name: Install dependencies
run: |
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/on_push_ExtraJobsForMain.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ jobs:

steps:
- uses: actions/checkout@v4
with:
submodules: true

- name: Install dependencies
run: |
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/on_push_clang_format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: true
- uses: DoozyX/clang-format-lint-action@v0.17
with:
source: '.'
Expand Down
6 changes: 6 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ jobs:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
with:
submodules: true

- name: Install dependencies
run: |
Expand Down Expand Up @@ -58,6 +60,8 @@ jobs:
runs-on: macos-latest
steps:
- uses: actions/checkout@v4
with:
submodules: true

- name: Install dependencies
run: |
Expand Down Expand Up @@ -96,6 +100,8 @@ jobs:
runs-on: windows-2022
steps:
- uses: actions/checkout@v4
with:
submodules: true

- name: Set up Visual Studio shell
uses: ilammy/msvc-dev-cmd@v1
Expand Down
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "xmpsdk/XMP-Toolkit-SDK"]
path = xmpsdk/XMP-Toolkit-SDK
url = https://github.com/adobe/XMP-Toolkit-SDK.git
6 changes: 4 additions & 2 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,9 @@ if(EXIV2_ENABLE_XMP OR EXIV2_ENABLE_EXTERNAL_XMP)
endif()

if(EXIV2_ENABLE_XMP)
target_sources(exiv2lib PRIVATE $<TARGET_OBJECTS:exiv2-xmp>)
# target_sources(exiv2lib PRIVATE $<TARGET_OBJECTS:exiv2-xmp>)
target_link_libraries(exiv2lib PRIVATE exiv2-xmp)
target_compile_definitions(exiv2lib PUBLIC EXV_ADOBE_XMPSDK=2016)
elseif(EXIV2_ENABLE_EXTERNAL_XMP)
target_link_libraries(exiv2lib PUBLIC ${XMPSDK_LIBRARY})
target_include_directories(exiv2lib PUBLIC ${XMPSDK_INCLUDE_DIR})
Expand Down Expand Up @@ -307,7 +309,7 @@ set(requires_private_for_pc_file

write_basic_package_version_file(exiv2ConfigVersion.cmake COMPATIBILITY ExactVersion)

install(TARGETS exiv2lib EXPORT exiv2Export)
install(TARGETS exiv2lib exiv2-xmp EXPORT exiv2Export)

include(CMakePackageConfigHelpers)
configure_package_config_file(
Expand Down
2 changes: 1 addition & 1 deletion src/convert.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1265,7 +1265,7 @@ std::string Converter::computeExifDigest(bool tiff) {
continue;
DataBuf data(pos->size());
pos->copy(data.data(), littleEndian /* FIXME ? */);
MD5Update(&context, data.c_data(), static_cast<uint32_t>(data.size()));
MD5Update(&context, const_cast<XMP_Uns8*>(data.c_data()), static_cast<uint32_t>(data.size()));
}
}
MD5Final(digest, &context);
Expand Down
36 changes: 30 additions & 6 deletions src/xmp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -634,8 +634,9 @@ void XmpParser::terminate() {
void XmpParser::registerNs(const std::string& ns, const std::string& prefix) {
try {
initialize();
AutoLock autoLock(xmpLockFct_, pLockData_);
SXMPMeta::DeleteNamespace(ns.c_str());
// apparently we can't delete namespaces anymore
// see WXMPMeta.cpp
// SXMPMeta::DeleteNamespace(ns.c_str());
#ifdef EXV_ADOBE_XMPSDK
SXMPMeta::RegisterNamespace(ns.c_str(), prefix.c_str(), nullptr);
#else
Expand Down Expand Up @@ -838,13 +839,36 @@ int XmpParser::encode(std::string& xmpPacket, const XmpData& xmpData, uint16_t f
if (!la)
throw Error(ErrorCode::kerEncodeLangAltPropertyFailed, xmp.key());

int idx = 1;
for (const auto& [lang, specs] : la->value_) {
if (!specs.empty()) { // remove lang specs with no value
printNode(ns, xmp.tagName(), specs, 0);
meta.AppendArrayItem(ns.c_str(), xmp.tagName().c_str(), kXMP_PropArrayIsAlternate, specs.c_str());
const std::string item = xmp.tagName() + "[" + toString(idx++) + "]";
meta.SetQualifier(ns.c_str(), item.c_str(), kXMP_NS_XML, "lang", lang.c_str());

// check if there is an item in the array with given lang
// I am sure this can be rewritten in a more optimal fashion
std::size_t item_cnt = meta.CountArrayItems(ns.c_str(), xmp.tagName().c_str());
std::size_t existing_item_idx = 0; // 0 means it does not exist
for (std::size_t i = 1; i <= item_cnt; ++i) {
std::string qualifier_value;
XMP_OptionBits qualifier_options;

const std::string item = xmp.tagName() + "[" + toString(i) + "]";

auto found = meta.GetQualifier(ns.c_str(), item.c_str(), kXMP_NS_XML, "lang", &qualifier_value,
&qualifier_options);
if (found and qualifier_value == lang) {
existing_item_idx = i;
break;
}
}

if (existing_item_idx) {
meta.SetArrayItem(ns.c_str(), xmp.tagName().c_str(), existing_item_idx, specs.c_str());
} else {
meta.AppendArrayItem(ns.c_str(), xmp.tagName().c_str(), kXMP_PropArrayIsAlternate, specs.c_str());
auto index = meta.CountArrayItems(ns.c_str(), xmp.tagName().c_str());
const std::string item = xmp.tagName() + "[" + toString(index) + "]";
meta.SetQualifier(ns.c_str(), item.c_str(), kXMP_NS_XML, "lang", lang.c_str());
}
}
}
continue;
Expand Down
Loading
Loading