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

Saving fails with 2021.4.0 #60

Closed cweiske closed 2 years ago

cweiske commented 3 years ago

I upgraded to 2021.4.0 to test multi-thumbnail reloading (#59) and now photini is useless: It does not save title or copyright anymore into the files, and always creates .xmp files.

Symptoms

  1. Open file: photini 01.png
  2. Select file in file list
  3. Add title "test" and photographer "test"
  4. Right-click file in file list, "Show changes"
  5. The two changes are visible
  6. Right-click file in file list, "Save changes"
  7. Right-click file in file list, "Close file"
  8. Popup appears: Some files have unsaved meta data. Save?
  9. Confirm by clicking "Save"
  10. Open file with file chooser dialog
  11. Select file
  12. Title and photographer is empty.
  13. A 01.png.xmp file has been created, but that misses the title and photographer as well.

The same happens when using "Save" in the "File" menu.

Version

photini --version
No module named 'gpxpy'
Photini 2021.4.0, build 1692 (52cba49)
  Python 3.9.2 (default, Feb 28 2021, 17:03:44) 
[GCC 10.2.1 20210110]
  PyGObject 3.38.0, GExiv2 0.12.1, GObject 2.0, GLib 2.66.2
  PyQt 5.15.2, Qt 5.15.2, using QtWebEngine
  ffmpeg version 4.3.2-0+deb11u1 Copyright (c) 2000-2021 the FFmpeg developers
  available styles: cleanlooks, gtk2, cde, motif, plastique, qt5ct-style, Windows, Fusion
  using style: qt5ct-style

I'm using a German language setting.

jim-easterbrook commented 3 years ago

That's very odd, and quite unlike anything I've seen before. I just tried your sequence on a .png file and it all worked as expected (but I'm using earlier versions of Python, PyGObject, GExiv2 and GLib). Can you run it with higher verbosity ('-v' or '-vv' on the command line) and see if there's any useful error messages.

cweiske commented 3 years ago

No additional output with -v, ,-vv and -vvv - only the same I got before:

No module named 'gpxpy'
No module named 'flickrapi'
No module named 'requests_oauthlib'

When using -vvv a popup window came that contains

06:16:05: INFO: stdout: No module named 'flickrapi'
06:16:05: INFO: stdout: No module named 'requests_oauthlib'
jim-easterbrook commented 3 years ago

No messages, even when attempting to save a file as before? What operating system are you using?

If you want to revert to the previous version of Photini you can install it with pip: pip install photini==2021.1.0

cweiske commented 3 years ago

I am using Debian unstable. Now I upgraded the system packages, and now photini works again. Sorry for the trouble of the unnecessary bug report.

The packages that got updated were:


base-passwd bash bison caja-nextcloud chromium chromium-common chromium-sandbox debian-mate-default-settings dh-strip-nondeterminism firefox firefox-l10n-de gir1.2-goa-1.0 gir1.2-gtk-2.0 gir1.2-gtk-3.0 gir1.2-javascriptcoregtk-4.0 gir1.2-webkit2-4.0 gnome-desktop3-data gnome-online-accounts gnome-settings-daemon gnome-settings-daemon-common gnome-sound-recorder graphviz gtk-update-icon-cache gtk2-engines-pixbuf htop libass9 libbcmail-java libbcpg-java libbcpkix-java libbcprov-java libcdt5 libcgraph6 libcpupower1 libdebconfclient0 libdjvulibre-text libdjvulibre21 libfile-stripnondeterminism-perl libfreerdp2-2 libgail-3-0 libgail-common libgail18 libgcrypt20 libgnome-desktop-3-19 libgoa-1.0-0b libgoa-1.0-common libgoa-backend-1.0-1 libgtk-3-0 libgtk-3-bin libgtk-3-common libgtk-3-dev libgtk2.0-0 libgtk2.0-0-dbgsym libgtk2.0-bin libgtk2.0-common libgtk2.0-dev libgvc6 libgvpr2 libjavascriptcoregtk-4.0-18 liblab-gamut1 libldap-2.4-2 libldap-common liblz4-1 libmariadb3 libmd4c0 libnextcloudsync0 libopenexr25 libpathplan4 libphonon4qt5-4 libphonon4qt5-data libpq5 libreadline8 libsmbclient libwbclient0 libwebkit2gtk-4.0-37 libwinpr2-2 libx11-6 libx11-data libx11-dev libx11-xcb1 libxml2 libxml2-utils linux-compiler-gcc-10-x86 linux-kbuild-5.10 linux-libc-dev lz4 mariadb-common mate-session-manager nextcloud-desktop nextcloud-desktop-common nextcloud-desktop-doc nextcloud-desktop-l10n phonon4qt5 php-symfony-config php-symfony-console php-symfony-dependency-injection php-symfony-filesystem php-symfony-finder php-symfony-process python-pip-whl python3-libxml2 python3-pip python3-samba python3-six python3-urllib3 readline-common redis redis-server redis-tools samba-common samba-common-bin samba-dsdb-modules samba-libs smbclient vinagre virtualbox virtualbox-dkms virtualbox-qt zenity zenity-common

jim-easterbrook commented 3 years ago

I can't see an obvious candidate in that list to cause your problem, but there's a few gtk ones in there that gexiv2 might be using. I suppose the point of Debian unstable is that sometimes things break. I prefer an older, more stable environment myself.

brightrain commented 2 years ago

Just chiming in to say that I had the same experience but on Windows with version 2021.7.0. Entered data for several jpg images but nothing was saved. A xmp file was created for each file but nothing saved in the image itself and nothing being written to the sidecar as far as I have seen either. Can provide more input if it would be helpful.

jim-easterbrook commented 2 years ago

I've just tried this on Ubuntu 20.04, with GExiv2 0.12.0, and am able to reproduce the problem. The exiv2 command line program (on the same machine) can set metadata without any problem, after which Photini works as you'd expect. So a nasty workaround is to set some data first:

exiv2 -M"add Exif.Image.ImageDescription Hello world" problem_file.jpg

and then run Photini.

I'll investigate further to see if I can find out what's happening.

jim-easterbrook commented 2 years ago

Eureka! In Photini I have a class ImageMetadata derived from GExiv2.MetaData. If an image can't be opened (e.g. a file format that exiv2 doesn't recognise) then the variable that's usually set to an instance of ImageMetadata is set to None. This variable is checked to see if Photini should attempt to save to the file. Recent versions of GExiv2 have got clever, so bool(GExiv2.MetaData) returns False if the metadata is empty!

jim-easterbrook commented 2 years ago

If anyone needs to fix their copy of Photini before the next release comes out, find the file exiv2.py in your installed copy of Photini, edit it and insert a __bool__ method just before the get_exif_thumbnail method (around line 150).

    def __bool__(self):
        return True

    def get_exif_thumbnail(self):
brightrain commented 2 years ago

Excellent @jim-easterbrook ! Thanks for the follow up and fix. So just to be sure I understand, is Photini not able to write directly to my jpg image files? And therefore the check to see if it can be written to fails? Just want to be sure I know what to test, but happy to do it. And make your recommended change.

jim-easterbrook commented 2 years ago

No, the problem with bool(GExiv2.MetaData) being False was that Photini thought it didn't have an image file it could write to, then thought it didn't have a sidecar it could write to. Once we provide our own __bool__ method then any writeable file should be written OK.

brightrain commented 2 years ago

Got it. I will try your fix tonight and report back.

brightrain commented 2 years ago

Making your update did the trick. All data is being saved directly to the jpg file and no sidecar files are being generated. Thanks for the quick fix and the awesome tool!

jim-easterbrook commented 2 years ago

Photini version 2021.9.0 is out now, and should fix this bug.