Bug 483743 - Fail to save exif date data for photo whose path contains non ASCII character
Summary: Fail to save exif date data for photo whose path contains non ASCII character
Status: RESOLVED FIXED
Alias: None
Product: digikam
Classification: Applications
Component: Metadata-Engine (show other bugs)
Version: 8.2.0
Platform: Microsoft Windows Microsoft Windows
: NOR normal
Target Milestone: ---
Assignee: Digikam Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-03-16 10:52 UTC by ntd2521998
Modified: 2024-05-01 11:51 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In: 8.4.0


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description ntd2521998 2024-03-16 10:52:59 UTC
SUMMARY
***
NOTE: If you are reporting a crash, please try to attach a backtrace with debug symbols.
See https://community.kde.org/Guidelines_and_HOWTOs/Debugging/How_to_create_useful_crash_reports
***


STEPS TO REPRODUCE
1.  Browse photo folders, which include folder that has non ASCII character (in my case: Z:\ExternalDrive\Pictures\BM\liên hoan cuối năm\
2.  Go to Item > Edit Metadata and make changes to Date & Time section
3. Click Apply or OK

alternatively:
1. same as above
2. Go to Item > Adjust Time & Date, makes changes
3. Go to Item > Write metadata to file
4. Observe the changes in actual file

Those behaviors in Album are the same

OBSERVED RESULT
datetime value isn't updated

EXPECTED RESULT
datetime value should be updated

SOFTWARE/OS VERSIONS
Windows 11 23H2

ADDITIONAL INFORMATION
Comment 1 Maik Qualmann 2024-03-16 11:13:05 UTC
In the Exiv2 Library, the developers have removed the function for wchar file paths on Windows. Other projects are also affected.
We are now planning to activate UTF-8 support in the Windows bundle for digiKam-8.4.0, this will fix the problem from Windows 10-1903.
Alternatively, you can activate the writing of metadata with ExifTool in the digiKam settings.

Maik
Comment 2 caulier.gilles 2024-03-16 12:40:04 UTC
Maik,

The MXE Windows build still using Exiv2 0.27 which do not have the problem as the wchar methods have been removed to Exiv2 0.28.

I don't know why the Exiv2 project do not check regression about this problem and do not reverse this important changes.

Note: Exiv2 report about this topic: https://github.com/Exiv2/exiv2/issues/2637

Gilles Caulier
Comment 3 Maik Qualmann 2024-03-16 14:34:36 UTC
Git commit 9bf12b2d04e2faaf05f98589b346e43d2f12a7a0 by Maik Qualmann.
Committed on 16/03/2024 at 14:32.
Pushed by mqualmann into branch 'master'.

prepare Exiv2 file paths to use UTF-8 on Windows in the MSVC build

M  +1    -1    core/libs/metadataengine/engine/metaengine_comments.cpp
M  +1    -1    core/libs/metadataengine/engine/metaengine_exif.cpp
M  +2    -2    core/libs/metadataengine/engine/metaengine_fileio.cpp
M  +1    -1    core/libs/metadataengine/engine/metaengine_iptc.cpp
M  +1    -1    core/libs/metadataengine/engine/metaengine_p.cpp
M  +1    -1    core/libs/metadataengine/engine/metaengine_previews.cpp
M  +1    -1    core/libs/metadataengine/engine/metaengine_xmp.cpp

https://invent.kde.org/graphics/digikam/-/commit/9bf12b2d04e2faaf05f98589b346e43d2f12a7a0
Comment 4 Maik Qualmann 2024-03-16 14:37:17 UTC
@Gilles, I need a new MSVC build.
I want to link a corresponding manifest file to digikam.exe using the Windows developer SDK and mt.exe in order to test UTF-8 file paths.

Maik
Comment 5 caulier.gilles 2024-03-16 14:54:14 UTC
Build is under progress with MSVC

Patch cmake rules to link with the manifest file, i will look if all works as expected at compilation under Windows.
Comment 6 caulier.gilles 2024-03-16 16:30:30 UTC
Maik, Windows installer 8.4.0 pre-release is online...
Comment 7 Maik Qualmann 2024-03-16 16:43:52 UTC
Yes, the server is a bit busy...

Maik
Comment 8 Maik Qualmann 2024-03-16 16:51:23 UTC
Ok, I started the download again, now a different mirror server is probably being used. The Windows SDK has also been at 11% for a while...

Maik
Comment 9 Maik Qualmann 2024-03-16 17:43:26 UTC
Git commit 782daf2855361a8c76bff2bc418006d979454f53 by Maik Qualmann.
Committed on 16/03/2024 at 17:42.
Pushed by mqualmann into branch 'master'.

upload digikam.exe.manifest file

A  +9    -0    project/bundles/vcpkg/data/digikam.exe.manifest

https://invent.kde.org/graphics/digikam/-/commit/782daf2855361a8c76bff2bc418006d979454f53
Comment 10 Maik Qualmann 2024-03-16 17:48:46 UTC
@Gilles, It works!
The command to apply the file is:

mt.exe -manifest <MANIFEST> -outputresource:<EXE>;#1

mt.exe -manifest digikam.exe.manifest -outputresource:digikam.exe;#1

But I think that there should also be a compile time way to apply the file, but I have to research it first.

Maik
Comment 11 Maik Qualmann 2024-03-16 17:51:58 UTC
We need to do the same with showFoto too.

Maik
Comment 12 caulier.gilles 2024-03-16 19:46:59 UTC
Dark table which use flame and have this kind of rules must have the command in source code

Look also in Krista which provide a windows version for the Asian country where this kind of support is mandatory for utf8 file paths
Comment 13 Maik Qualmann 2024-03-16 20:36:45 UTC
Darktable seems to be using winuser.rh with "RT_MANIFEST" after this commit.

https://github.com/darktable-org/darktable/pull/15899/commits/83a11d192bf2ea33092554410bde05f42f205138

https://learn.microsoft.com/de-de/windows/win32/menurc/resource-types

Krita uses a QIODevice loader for everything.
 
Maik
Comment 14 Maik Qualmann 2024-03-17 18:37:02 UTC
Git commit 323471a7c2fae67070c421dafd08aada0f04f5d9 by Maik Qualmann.
Committed on 17/03/2024 at 18:36.
Pushed by mqualmann into branch 'master'.

try to add manifest file in the build process

M  +6    -0    project/bundles/vcpkg/04-build-installer.sh

https://invent.kde.org/graphics/digikam/-/commit/323471a7c2fae67070c421dafd08aada0f04f5d9
Comment 15 Maik Qualmann 2024-03-17 18:38:56 UTC
@Gilles, can you please test whether it works. I don't know if you have the Windows SDK installed or if the mt.exe is in the Visual Studio path.

Maik
Comment 16 caulier.gilles 2024-03-17 21:13:49 UTC
ok, i will check that asap...

Gilles
Comment 17 Maik Qualmann 2024-03-17 21:34:29 UTC
Git commit 01a9335e809fed138928b8d602162711ea63337c by Maik Qualmann.
Committed on 17/03/2024 at 21:33.
Pushed by mqualmann into branch 'master'.

another probably copy/paste error

M  +2    -2    core/libs/metadataengine/focuspoint/focuspoints_extractor_canon.cpp

https://invent.kde.org/graphics/digikam/-/commit/01a9335e809fed138928b8d602162711ea63337c
Comment 18 Maik Qualmann 2024-03-17 21:43:24 UTC
Comment 17 should be posted on Bug 483839

Maik
Comment 19 caulier.gilles 2024-03-18 21:13:29 UTC
Maik,

---------- Apply manifest file to enable UTF-8 support for file paths

./04-build-installer.sh: line 271: /c/Program Files (x86)/Windows Kits/10/bin/x64/mt: No such file or directory
FAILED COMMAND: "/c/Program Files (x86)/Windows Kits/10/bin/x64/mt" -manifest $ORIG_WD/data/digikam.exe.manifest -outputresource:$VCPKG_INSTALL_PREFIX/bin/digikam.exe
---------- Cleanup older bundle logs from files.kde.org repository

It miss something to install on the VM. I will take a look

Gilles
Comment 20 Maik Qualmann 2024-03-18 21:23:57 UTC
The "mt.exe" can also be located somewhere in the Visual Studio directory. The "mt.exe" only has one config file, no other dependencies, it can also be copied to another location.

Maik
Comment 21 Maik Qualmann 2024-03-19 08:56:56 UTC
Gilles, you have to select the optional component "Visual Studio Extensions Development" (translated from German) in the Visual Studio installer to get the mt.exe.

Alternatively, you can install the SDK from here: https://developer.microsoft.com/en-us/windows/downloads/windows-sdk/

Maik
Comment 22 caulier.gilles 2024-03-19 09:25:47 UTC
yes, i will install the missing component from the MSVC setup. I will do it this evening and try again.
Comment 23 caulier.gilles 2024-03-20 07:36:51 UTC
The executable is already installed on the VM through the Visual Studio 2022 installer :

https://imgur.com/a/dDKPnsG

The only rules to add is a search of this tool in Windows Kits directory as it's already done with DumpBin.exe program :

https://invent.kde.org/graphics/digikam/-/blob/master/project/bundles/vcpkg/04-build-installer.sh?ref_type=heads#L56

The VisualStudio CLI tool are not in the PATH on the console (why ??? it's another opaque point from M$)

Searching for CLI tool path allows to hard code path in script which breaks the compatibility between Windows kits versions in time...

Gilles
Comment 24 caulier.gilles 2024-03-20 07:45:00 UTC
Git commit a6e9d3af64e1ad1fca91db586526282052cad07f by Gilles Caulier.
Committed on 20/03/2024 at 07:44.
Pushed by cgilles into branch 'master'.

search for mt.exe CLI tool from Windows Kits

M  +16   -2    project/bundles/vcpkg/04-build-installer.sh

https://invent.kde.org/graphics/digikam/-/commit/a6e9d3af64e1ad1fca91db586526282052cad07f
Comment 25 caulier.gilles 2024-03-20 07:46:47 UTC
/c/Program Files (x86)/NSIS/Bin/makensis
Check NSIS CLI tools passed...
/c/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.37.32822/bin/Hostx64/x64/dumpbin.exe
Check DumpBin CLI tools passed...
/c/Program Files (x86)/Windows Kits/10/bin/10.0.22621.0/x64/mt.exe
Check Mt CLI tools passed...
/c/Program Files/ImageMagick-7.1.1-Q16-HDRI
Check ImageMagick install path passed...
Comment 26 caulier.gilles 2024-03-20 07:49:13 UTC
It's works:

...
---------- Apply manifest file to enable UTF-8 support for file paths

Microsoft (R) Manifest Tool
Copyright (c) Microsoft Corporation.
All rights reserved.

---------- Copy executables with recursive dependencies in bundle directory

Scan dependencies for /e/dk/x64-windows/bin/digikam.exe
Scan dependencies for /e/dk/x64-windows/bin/digikam.dll
...
Comment 27 Maik Qualmann 2024-03-20 09:08:20 UTC
Great, it works! Exiv2 can now write and read metadata in file paths with characters that are outside the Windows code page.

I will add support for showFoto. Maybe we should create the manifest files from a template, as they contain a version string and we would otherwise have to change this manually with a new digiKam version.

Theoretically, we can now add UTF-8 support to many libraries that we now make special adjustments with wchar or QIODevice on Windows, e.g. libRaw, libheif, libjpg, libtiff, etc.

But we still need this for MinGW/Windows7 support.

Maik
Comment 28 caulier.gilles 2024-03-20 09:23:45 UTC
> will add support for showFoto. Maybe we should create the manifest files from a template, as they contain a version string and we would >otherwise have to change this manually with a new digiKam version.

yes, the template is the good way. There are template files already used in core/cmake/template/

Gilles
Comment 29 caulier.gilles 2024-03-20 09:33:05 UTC
Maik,

Look like the manifest file from Krita is really huge, due to the signing application rules for the store:

https://invent.kde.org/graphics/krita/-/blob/master/packaging/windows/msix/manifest.xml.in?ref_type=heads

But there are also type mime rules inside for ex.

Gilles
Comment 30 caulier.gilles 2024-03-20 09:34:27 UTC
Note: krita do not have UFT8 support for file path as i can see. The manifest do not include similar rule than the new from digiKam...
Comment 31 Maik Qualmann 2024-03-20 19:50:25 UTC
Git commit d7ff3a9747b978a1b95eaf42dfa49a5761a3c902 by Maik Qualmann.
Committed on 20/03/2024 at 19:49.
Pushed by mqualmann into branch 'master'.

add cmake template to generate the manifest file with version

M  +8    -0    core/app/DigikamTarget.cmake
R  +1    -1    core/cmake/templates/digikam.exe.manifest.cmake.in [from: project/bundles/vcpkg/data/digikam.exe.manifest - 070% similarity]
M  +1    -1    project/bundles/vcpkg/04-build-installer.sh

https://invent.kde.org/graphics/digikam/-/commit/d7ff3a9747b978a1b95eaf42dfa49a5761a3c902
Comment 32 Maik Qualmann 2024-03-20 19:58:19 UTC
Git commit 133d8a17f245c290e0534a7734fdea61825954a8 by Maik Qualmann.
Committed on 20/03/2024 at 19:57.
Pushed by mqualmann into branch 'master'.

add manifest file to showFoto

A  +9    -0    core/cmake/templates/showfoto.exe.manifest.cmake.in
M  +8    -0    core/showfoto/CMakeLists.txt
M  +4    -0    project/bundles/vcpkg/04-build-installer.sh

https://invent.kde.org/graphics/digikam/-/commit/133d8a17f245c290e0534a7734fdea61825954a8
Comment 33 Maik Qualmann 2024-03-23 12:29:57 UTC
Exiv2 now works with file paths that have characters outside the current Windows code page. I'll close now.

https://files.kde.org/digikam/

Maik
Comment 34 caulier.gilles 2024-03-23 15:50:17 UTC
Maik,

To be clear here, this file is only relevant of the native Windows version compiled with MSVC and using Exiv2 >= 0.28.0.
The cross compiled version with MXE still use Exiv2 0.27 to support UTF-8 path. If we upgrade to last 0.28, all will be broken.

Gilles
Comment 35 Maik Qualmann 2024-03-23 17:28:21 UTC
Yes, exactly, with MXE and Exiv2-0.28 the problem would be present again.
The question would be, can the manifest file also be applied to a digiKam.exe if it was created by MinGW. I will test it.

Maik
Comment 36 caulier.gilles 2024-03-23 18:14:47 UTC
The Microsoft Mt.exe tool is only available under Windows. I doubt that a MinGW equivalent exists...

Gilles
Comment 37 caulier.gilles 2024-03-23 18:16:37 UTC
Hum, perhaps a solution here :

https://stackoverflow.com/questions/20255591/manifest-being-ignored-in-mingw-app

Gilles
Comment 38 Maik Qualmann 2024-03-23 18:22:10 UTC
My idea would have been Wine, but "winuser.h" also uses darktable:

https://github.com/darktable-org/darktable/pull/15899/files

serach for "winuser"

Maik
Comment 39 caulier.gilles 2024-05-01 11:34:41 UTC
Git commit 9bc678024d7de9585564f054984a824ac6be55ac by Gilles Caulier.
Committed on 01/05/2024 at 11:29.
Pushed by cgilles into branch 'master'.

try to activate Windows manifest descriptions under MXE

M  +1    -1    core/app/DigikamTarget.cmake
M  +1    -1    core/showfoto/CMakeLists.txt

https://invent.kde.org/graphics/digikam/-/commit/9bc678024d7de9585564f054984a824ac6be55ac
Comment 40 caulier.gilles 2024-05-01 11:36:08 UTC
Git commit 9aca251532036b8207db07538318d2bc5130bcd3 by Gilles Caulier.
Committed on 01/05/2024 at 11:35.
Pushed by cgilles into branch 'master'.

switch to Exiv2 0.28.2 under MXE

M  +2    -2    project/bundles/3rdparty/ext_exiv2/CMakeLists.txt

https://invent.kde.org/graphics/digikam/-/commit/9aca251532036b8207db07538318d2bc5130bcd3
Comment 41 caulier.gilles 2024-05-01 11:47:07 UTC
Git commit 010699c40a404d1c5e0b6f064751d98e2aa79da8 by Gilles Caulier.
Committed on 01/05/2024 at 11:46.
Pushed by cgilles into branch 'master'.

apply patch for mmap support under MXE

M  +2    -2    project/bundles/3rdparty/ext_exiv2/CMakeLists.txt

https://invent.kde.org/graphics/digikam/-/commit/010699c40a404d1c5e0b6f064751d98e2aa79da8
Comment 42 caulier.gilles 2024-05-01 11:51:31 UTC
Maik,

I enabled the manifest files install under MXE and build the 0.28.2 version instead 0.27-maintenance branch (unmaintained since a while)

Qt5 based Installer 8.4.0 pre-release will be online in one hour.

Gilles