0

This works perfectly when run as a Python program, but as a Flatpak it always fails on image.getexif().

The Python has:

from PIL import Image, ExifTags, ImageOps 
from PIL.ExifTags import TAGS

if os.path.isfile(myfile):
    image = Image.open(myfile)
else:       
    return -2
try:
    image_exif = image.getexif()
except:
    test = 'image_exif failed'

The Flatpak has:

  - name: python3-pillow
    buildsystem: simple
    build-commands:
      - pip3 install --no-index --find-links="file://${PWD}" --prefix=${FLATPAK_DEST} Pillow
    sources:
      - type: file
        url: https://files.pythonhosted.org/packages/3c/7e/443be24431324bd34d22dd9d11cc845d995bcd3b500676bcf23142756975/Pillow-5.4.1.tar.gz
        sha256: 5233664eadfa342c639b9b9977190d64ad7aca4edc51a966394d7e08e7f38a9f

Is it likely to be the Pillow version? Python on my PC is 8.3.2, but the Flatpak gets 5.4.1.

  • How does it fail? Your blanket `except` isn't telling you the details. – Tim Roberts Sep 12 '22 at 21:47
  • I don't know what a "blanket except" is. I don't know how to find out the details of the failure, but I'm wondering whether the earlier version of Pillow did getexif() differently. It imports ExifTags and TAGS OK though. –  Sep 12 '22 at 22:20
  • You have `except:` by itself. That will trap ALL exceptions, including those you want to know about, like this one. Get rid of the `try/except`, and the message should tell you what's going wrong. – Tim Roberts Sep 13 '22 at 00:43
  • I couldn't see the errors when I ran the Flatpak, which is why I trapped it. I've now changed it to: "except AssertionError as error: test = error." It suppose might have shown had I run it from a terminal. I can't try either of these things though, as building the Flatpak now fails - despite having changed nothing in the Manifest. I'll have to fix that first, then come back to this. –  Sep 13 '22 at 18:59
  • Flatpak problem fixed. I've removed the except: and run it from the terminal, I get the error "AttributeError: 'JpegImageFile' object has no attribute 'getexif' ". That's odd as it works as a Python program - see above. I've also put in a statement to check the Pillow version. The Flatpak one is much older so it's probably that. –  Sep 18 '22 at 22:55

1 Answers1

0

I added this to the program

from PIL import __version__

then

Print(__version__)

I removed the error trapping, then instead of running the Flatpak from a menu, I ran it from a terminal. That showed the Pillow version and the error. The Pillow version on my computer was 8.3.2 and that in the Flatpak was only 5.4.1. The function I had added to my program was obviously different or missing from the earlier version. Updating the Pillow version in the Flatpak fixed the problem.