rbreu / beeref

BeeRef Reference Image Viewer
GNU General Public License v3.0
531 stars 40 forks source link

Freez when loading a "jpeg" image, other image have no problem #111

Closed aionoid closed 5 months ago

aionoid commented 6 months ago

Describe the bug

trying to load a "jpeg" image and it will freez

System info

BeeRef version number: 0.3.3 Your operating system: linux arch Linux 6.8.5-zen1-1-zen #1 ZEN SMP PREEMPT_DYNAMIC Thu, 11 Apr 2024 01:47:18 +0000 x86_64 GNU/Linux

To Reproduce Steps to reproduce the behavior:

  1. loading the attached image

Expected behavior

load the image

Screenshots If applicable, add screenshots to help explain your problem. test

Debug log: For crashes and similar, provide the last 20 lines or so of your debug log. To get the debug log, open BeeRef and go to Help -> Show Debug Log. If in doubt, paste the whole debug log to a paste service like paste.bin

2024-05-13 18:02:25,193 Qt 17900 133260916102976 "/usr/lib/qt6/plugins/kf6/kwindowsystem/KF6WindowSystemX11Plugin.so" loaded library
2024-05-13 18:02:27,758 beeref.main_controls 17900 133260916102976 Drag enter event: ['text/uri-list']
2024-05-13 18:02:28,072 beeref.main_controls 17900 133260916102976 Handling file drop: ['text/uri-list']
2024-05-13 18:02:28,074 beeref.main_controls 17900 133260916102976 Found dropped urls: [PyQt6.QtCore.QUrl('file:///home/owo/Documents/assets/boughnama/boughnama/Screenshot_20240319-232817.jpg')]
2024-05-13 18:02:28,075 beeref.widgets 17900 133260916102976 Initialised progress bar
2024-05-13 18:02:28,075 beeref.fileio 17900 133260675909312 Loading image from file PyQt6.QtCore.QUrl('file:///home/owo/Documents/assets/boughnama/boughnama/Screenshot_20240319-232817.jpg')
2024-05-13 18:02:28,076 beeref.widgets 17900 133260916102976 Beginn progress dialog: 1
2024-05-13 18:02:28,082 beeref.__main__ 17900 133260675909312 Unhandled exception
Traceback (most recent call last):
  File "/usr/lib/python3.11/site-packages/beeref/fileio/__init__.py", line 100, in run
    self.func(*self.args, **self.kwargs)
  File "/usr/lib/python3.11/site-packages/beeref/fileio/__init__.py", line 63, in load_images
    img, filename = load_image(filename)
                    ^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/beeref/fileio/image.py", line 90, in load_image
    return (exif_rotated_image(path), path)
            ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/beeref/fileio/image.py", line 50, in exif_rotated_image
    orientation = exifimg.orientation
                  ^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/exif/_image.py", line 104, in __getattr__
    return getattr(self._segments["APP1"], item)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/exif/_app1_metadata.py", line 600, in __getattr__
    return ifd_tag.read()
           ^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/exif/ifd_tag/_short.py", line 96, in read
    retval = enum_type(as_int)
             ^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/enum.py", line 712, in __call__
    return cls.__new__(cls, value)
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/enum.py", line 1135, in __new__
    raise ve_exc
ValueError: 0 is not a valid Orientation
rbreu commented 5 months ago

I can't reproduce it with the attached image; most likely because github ran its own image processing on the image when you attached the file.

But the error message seems clear enough. The problem was that the image rotation in the exif metadata was stored in a way the library I used doesn't understand. The problem should be fixed now on the dev version and will go out with the next release.