jim-easterbrook / Photini

An easy to use digital photograph metadata (Exif, IPTC, XMP) editing application.
https://photini.readthedocs.io/
GNU General Public License v3.0
156 stars 24 forks source link

Error if accents in filename #52

Closed Arczt closed 3 years ago

Arczt commented 3 years ago

Hello, When I try to save a photo after modifying metadata, I have this error message :

11:25:30: ERROR: photini.exiv2: GExiv2: D:\Temp\Photini\photo_with_é.jpg.xmp: Failed to open the data source: No such file or directory (errno = 2) (9)
Traceback (most recent call last):
  File "C:\Program Files (x86)\Photini\msys2\mingw64\lib\python3.7\site-packages\photini\exiv2.py", line 744, in open_new
    self = cls(sc_path)
  File "C:\Program Files (x86)\Photini\msys2\mingw64\lib\python3.7\site-packages\photini\exiv2.py", line 75, in __init__
    self.open_path(self._path)
  File "C:\Program Files (x86)\Photini\msys2\mingw64\lib\python3.7\site-packages\gi\overrides\GExiv2.py", line 44, in open_path
    super(Metadata, self).open_path(path)
gi.repository.GLib.GError: GExiv2: D:\Temp\Photini\photo_with_é.jpg.xmp: Failed to open the data source: No such file or directory (errno = 2) (9)

There is a accent the the file name. When removing it (photo_with_é.jpg => photo_with_e.jpg), everything works fine. Same issue with other non ascii characters. (And congratulations for the great job !)

jim-easterbrook commented 3 years ago

That really shouldn't be happening. I've just tried it on Linux and there isn't a problem.

Did it successfully read metadata from the photo_with_é.jpg file? If so, then there's only a problem with writing files. (It tries to create a .xmp file if it failed to write to the .jpg file.)

I'll do some tests on Windows and report back later.

jim-easterbrook commented 3 years ago

OK, I've recreated the problem. I think it might be related to this https://dev.exiv2.org/boards/3/topics/1926 which is also using the MSYS2 build of exiv2.

jim-easterbrook commented 3 years ago

See also https://dev.exiv2.org/boards/3/topics/2944

I get the feeling the exiv2 project might not fix this, and I don't think there's anything I can sensibly do in Photini (copy file to a temporary safe name?, rename the file?).

jim-easterbrook commented 3 years ago

Hmm. I just tried running the mingw64.exe shell that's part of MSYS2 as installed by the Photini installer and then using exiv2 directly:

$ exiv2 -pa "C:\Users\Jim\Pictures\fünny_name.JPG"
Error: Directory Canon with 6144 entries considered invalid; not read.
Exif.Image.ProcessingSoftware                Ascii      26  Photini editor v2020.10.0
Exif.Image.ImageDescription                  Ascii      78  Château-Gontier, France
Exif.Image.Make                              Ascii       6  Canon
Exif.Image.Model                             Ascii      25  Canon PowerShot A1100 IS
Exif.Image.Orientation                       Short       1  top, left
...

More investigation needed.

jim-easterbrook commented 3 years ago

Exiv2 and MSYS2 appear to have done what's needed: https://github.com/msys2/MINGW-packages/pull/2837

jim-easterbrook commented 3 years ago

My next thought was maybe gexiv2 on MSYS is failing. GIMP uses gexiv2, so I installed it and used it to open fünny_name.JPG and export it to another file. It copied the metadata correctly, so the problem probably isn't in gexiv2.

jim-easterbrook commented 3 years ago

A short test script shows the problem:

import sys

import gi
gi.require_version('GExiv2', '0.10')
from gi.repository import GExiv2

def main():
    for path in sys.argv[1:]:
        print(path)
        md = GExiv2.Metadata()
        md.open_path(path)
        print(md.get_exif_tags())
    return 0

if __name__ == "__main__":
    sys.exit(main())
jim-easterbrook commented 3 years ago

GIMP have also had problems: https://gitlab.gnome.org/GNOME/gimp/-/issues/1350

jim-easterbrook commented 3 years ago

I've sought help from the MSYS2 project: https://github.com/msys2/MINGW-packages/issues/7167

jim-easterbrook commented 3 years ago

And now from the GExiv2 project: https://gitlab.gnome.org/GNOME/gexiv2/-/issues/59

jim-easterbrook commented 3 years ago

This doesn't work if the folder has accents in its name!

jim-easterbrook commented 3 years ago

I think I have the best compromise solution now.

jim-easterbrook commented 3 years ago

Released in version 2020.10.0 and after.

Arczt commented 3 years ago

I tried with my tests files, and it works fine !