I can use metadata-exiv2
branch to decode CR3 metadata. The branch is old (May 2021). I would like to try and update metadata-exiv2
branch to include commits from current dev.
There is a metadata-exiv2
branch in #5889. The idea is to use exiv2 in RT. There is a corresponding issue report CR3 metadata decoding support · Issue #6248 · Beep6581/RawTherapee · GitHub. This is labeled v6.0 milestone.
I tried the metadata-exiv2
branch. It works for me with patch proposed by @feuerrot in rtengine/imagedata.cc and exiv2 upgraded to v0.27.5 with -DEXIV2_ENABLE_BMFF=On. I can now see and use:
- metadata in main editor window
- Color tab | color management | auto-matched camera profile is selectable
- Transform Tab | Profiled Lens correction | automatically selected seems to work and picks up camera and lens.
metadata-exiv2
branch is old (May 2021). This branch is 15 commits ahead, 255 commits behind dev. Exiv2 support is a main change. It can stay in the feature branch, but I would like to try and update metadata-exiv2
branch to include commits from current dev.
This is what I did (long, but simple in principle) on Debian stable 11.3:
Build exiv2 v0.27.5 with -DEXIV2_ENABLE_BMFF=On
mkdir ${HOME}/test/rt_exiv2
cd ${HOME}/test/rt_exiv2
git clone https://github.com/Exiv2/exiv2.git
cd exiv2
git checkout v0.27.5
mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=Release -DEXIV2_ENABLE_BMFF=On -DCMAKE_INSTALL_PREFIX="$HOME/test/rt_exiv2" ..
make --build . -j8
cmake --install .
Make sure RT find local exiv2 library and not system version. I put this into a file rt_definitions.sh
RT_PREFIX=${HOME}/test/rt_exiv2
# Used to find programs/tools during build
export PATH="${RT_PREFIX}/bin:$PATH"
# Used to detect the build dependencies
export PKG_CONFIG_PATH="${RT_PREFIX}/share/pkgconfig:${RT_PREFIX}/lib/pkgconfig${PKG_CONFIG_PATH:+:$PKG_CONFIG_PATH}"
# Used to find the glib-introspection dependencies
export XDG_DATA_DIRS="${XDG_DATA_DIRS:+$XDG_DATA_DIRS:}${RT_PREFIX}/share:/usr/local/share:/usr/share"
# Used to find the libraries at runtime
export LD_LIBRARY_PATH="${RT_PREFIX}/lib:${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}"
arch="$(dpkg-architecture -qDEB_HOST_MULTIARCH 2> /dev/null)"
export PKG_CONFIG_PATH="${RT_PREFIX}/lib/${arch}/pkgconfig:$PKG_CONFIG_PATH"
export LD_LIBRARY_PATH="${RT_PREFIX}/lib/${arch}:${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}"
Source definitions:
source rt_definitions.sh
Get RT metadata-exiv2
branch:
cd ${HOME}/test/rt_exiv2
git clone https://github.com/Beep6581/RawTherapee.git
cd RawTherapee
git checkout --track origin/metadata-exiv2
Patch rtengine/imagedata.cc. Add one line Exiv2::enableBMFF(true);
Exiv2::Image::AutoPtr open_exiv2(const Glib::ustring& fname)
{
/// Patch to enable BMFF
Exiv2::enableBMFF(true);
/// End of patch
#ifdef EXV_UNICODE_PATH
glong ws_size = 0;
gunichar2* const ws = g_utf8_to_utf16(fname.c_str(), -1, nullptr, &ws_size, nullptr);
std::wstring wfname;
wfname.reserve(ws_size);
for (glong i = 0; i < ws_size; ++i) {
wfname.push_back(ws[i]);
}
g_free(ws);
auto image = Exiv2::ImageFactory::open(wfname);
#else
auto image = Exiv2::ImageFactory::open(fname);
#endif
return image;
}
Build RT:
cd ${HOME}/test/rt_exiv2/RawTherapee
mkdir build
cd build
cmake \
-DCMAKE_BUILD_TYPE="release" \
-DCACHE_NAME_SUFFIX="5-dev" \
-DPROC_TARGET_NUMBER="2" \
-DBUILD_BUNDLE="ON" \
-DBUNDLE_BASE_INSTALL_DIR="$HOME/test/rt_exiv2/install" \
-DOPTION_OMP="ON" \
-DWITH_LTO="OFF" \
-DWITH_PROF="OFF" \
-DWITH_SAN="OFF" \
-DWITH_SYSTEM_KLT="OFF" \
..
make -j8
make install
I can now run the feature branch and decode CR3 metadata (I have to make sure I have executed source rt_definitions.sh
in the console I use):
cd ${HOME}/test/rt_exiv2/install
./RawTherapee
This is great fun, but there are many needed commits in dev which we need to merge to get a useful RT.
Since metadata-exiv2
branch 15 commits ahead, 255 commits behind It is a hard job to merge into dev:
This is what git merge metadata-exiv2
results in when merging into current dev (after committing small Exiv2::enableBMFF(true);
patch to metadata-exiv2:
cd ${HOME}/test/rt_exiv2/RawTherapee
git checkout dev
git merge metadata-exiv2
Removing tools/generateRtexifUpdates
Auto-merging rtgui/thumbnail.h
CONFLICT (content): Merge conflict in rtgui/thumbnail.h
Auto-merging rtgui/thumbnail.cc
Auto-merging rtgui/filmnegative.cc
Auto-merging rtgui/editwidgets.h
Auto-merging rtgui/editwidgets.cc
Auto-merging rtgui/editorpanel.cc
CONFLICT (content): Merge conflict in rtgui/editorpanel.cc
Auto-merging rtgui/controlspotpanel.cc
Auto-merging rtgui/controllines.h
Auto-merging rtgui/controllines.cc
Auto-merging rtgui/CMakeLists.txt
Removing rtexif/stdattribs.cc
Removing rtexif/sonyminoltaattribs.cc
CONFLICT (modify/delete): rtexif/rtexif.h deleted in metadata-exiv2 and modified in HEAD. Version HEAD of rtexif/rtexif.h left in tree.
CONFLICT (modify/delete): rtexif/rtexif.cc deleted in metadata-exiv2 and modified in HEAD. Version HEAD of rtexif/rtexif.cc left in tree.
Removing rtexif/pentaxattribs.cc
Removing rtexif/panasonicattribs.cc
CONFLICT (modify/delete): rtexif/olympusattribs.cc deleted in metadata-exiv2 and modified in HEAD. Version HEAD of rtexif/olympusattribs.cc left in tree.
Removing rtexif/nikonattribs.cc
Removing rtexif/kodakattribs.cc
Removing rtexif/fujiattribs.cc
Removing rtexif/canonattribs.cc
Removing rtexif/CMakeLists.txt
Auto-merging rtengine/simpleprocess.cc
Auto-merging rtengine/rtthumbnail.cc
CONFLICT (content): Merge conflict in rtengine/rtthumbnail.cc
Auto-merging rtengine/rtengine.h
Removing rtengine/rawmetadatalocation.h
Auto-merging rtengine/rawimagesource.cc
Auto-merging rtengine/procparams.h
Auto-merging rtengine/procparams.cc
Removing rtengine/iptcpairs.h
Auto-merging rtengine/iplocallab.cc
Auto-merging rtengine/improcfun.h
Auto-merging rtengine/improcfun.cc
Auto-merging rtengine/improccoordinator.cc
Auto-merging rtengine/imagesource.h
CONFLICT (content): Merge conflict in rtengine/imagesource.h
Auto-merging rtengine/imageio.h
Auto-merging rtengine/imageio.cc
CONFLICT (content): Merge conflict in rtengine/imageio.cc
Auto-merging rtengine/imagedata.cc
CONFLICT (content): Merge conflict in rtengine/imagedata.cc
Auto-merging rtengine/dfmanager.cc
Auto-merging rtengine/dcrop.cc
Auto-merging rtengine/dcp.h
Auto-merging rtengine/dcp.cc
Auto-merging rtengine/CMakeLists.txt
Auto-merging CMakeLists.txt
I tried to resolve merge conflicts (content) and keep files deleted in metadata-exiv2 (modify/delete). Then I got:
[ 1%] Building CXX object rtengine/CMakeFiles/rtengine.dir/dcp.cc.o
/home/magnus/test/rt_exiv2/RawTherapee/rtengine/dcp.cc: In constructor ‘rtengine::DCPProfile::DCPProfile(const Glib::ustring&)’:
/home/magnus/test/rt_exiv2/RawTherapee/rtengine/dcp.cc:1121:54: error: no matching function for call to ‘fopen(const char*, const char [3])’
1121 | FILE* const file = g_fopen(filename.c_str(), "rb");
But rtengine/dcp.cc
was auto-merged.
It was a nice try! I ended up breaking something fundamental since RT code has many existing references to g_fopen(filename.c_str(), "rb")
.
How to fix this to get metadata-exiv2
branch to include current dev commits? It would be a lovely hack. I have tried, but not yet succeed. What do you think?