Some image files (that used to be okay) cannot be opened/imported
(Behavior in non-debug mode is described below.)
File A
In debug mode, when the following image folder is selected for new project or import, the application crashes. I think this crash is relatively new, this image used to work.
C:\Users\Karel\miniconda3\envs\arth\python.exe "G:\Work\JetBrains\PyCharm Community Edition 2022.1\plugins\python-ce\helpers\pydev\pydevd.py" --multiprocess --qt-support=auto --client 127.0.0.1 --port 57426 --file D:/work/arthropods/arthropoddescriber2repository/arthropod_describer_py/arthropod_describer/app.py
Connected to pydev debugger (build 221.5080.212)
__file__ is D:\work\arthropods\arthropoddescriber2repository\arthropod_describer_py\arthropod_describer\plugin_manager.py
returning plugin paths D:\work\arthropods\arthropoddescriber2repository\arthropod_describer_py\arthropod_describer\plugins\pekar_unet
D:\work\arthropods\arthropoddescriber2repository\arthropod_describer_py\arthropod_describer\plugins\profile_register
D:\work\arthropods\arthropoddescriber2repository\arthropod_describer_py\arthropod_describer\plugins\test_plugin
loading D:\work\arthropods\arthropoddescriber2repository\arthropod_describer_py\arthropod_describer\plugins\pekar_unet
loading D:\work\arthropods\arthropoddescriber2repository\arthropod_describer_py\arthropod_describer\plugins\profile_register
loading D:\work\arthropods\arthropoddescriber2repository\arthropod_describer_py\arthropod_describer\plugins\test_plugin
setting "projects_folder" to D:\work\arthropods\Projects
Traceback (most recent call last):
File "C:\Users\Karel\miniconda3\envs\arth\lib\site-packages\PIL\JpegImagePlugin.py", line 629, in _save
rawmode = RAWMODE[im.mode]
KeyError: 'RGBA'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "D:\work\arthropods\arthropoddescriber2repository\arthropod_describer_py\arthropod_describer\import_dialog.py", line 477, in _handle_import_txtInput_changed
self.thumbnail_storage = ThumbnailStorage_(self.temp_storage, thumbnail_size=(128, 64))
File "D:\work\arthropods\arthropoddescriber2repository\arthropod_describer_py\arthropod_describer\thumbnail_storage.py", line 31, in __init__
self._load_thumbnails()
File "D:\work\arthropods\arthropoddescriber2repository\arthropod_describer_py\arthropod_describer\thumbnail_storage.py", line 36, in _load_thumbnails
self._generate_thumbnail(img)
File "D:\work\arthropods\arthropoddescriber2repository\arthropod_describer_py\arthropod_describer\thumbnail_storage.py", line 44, in _generate_thumbnail
im.save(self._location / photo.image_path.name, 'JPEG')
File "C:\Users\Karel\miniconda3\envs\arth\lib\site-packages\PIL\Image.py", line 2240, in save
save_handler(self, fp, filename)
File "C:\Users\Karel\miniconda3\envs\arth\lib\site-packages\PIL\JpegImagePlugin.py", line 631, in _save
raise OSError(f"cannot write mode {im.mode} as JPEG") from e
OSError: cannot write mode RGBA as JPEG
Process finished with exit code 1
File B
A different crash happens when selecting the following folder (same image modified and re-saved in an editor, also used to work):
Folder_with_cremcast_5-straightened.zip
C:\Users\Karel\miniconda3\envs\arth\python.exe "G:\Work\JetBrains\PyCharm Community Edition 2022.1\plugins\python-ce\helpers\pydev\pydevd.py" --multiprocess --qt-support=auto --client 127.0.0.1 --port 57443 --file D:/work/arthropods/arthropoddescriber2repository/arthropod_describer_py/arthropod_describer/app.py
Connected to pydev debugger (build 221.5080.212)
__file__ is D:\work\arthropods\arthropoddescriber2repository\arthropod_describer_py\arthropod_describer\plugin_manager.py
returning plugin paths D:\work\arthropods\arthropoddescriber2repository\arthropod_describer_py\arthropod_describer\plugins\pekar_unet
D:\work\arthropods\arthropoddescriber2repository\arthropod_describer_py\arthropod_describer\plugins\profile_register
D:\work\arthropods\arthropoddescriber2repository\arthropod_describer_py\arthropod_describer\plugins\test_plugin
loading D:\work\arthropods\arthropoddescriber2repository\arthropod_describer_py\arthropod_describer\plugins\pekar_unet
loading D:\work\arthropods\arthropoddescriber2repository\arthropod_describer_py\arthropod_describer\plugins\profile_register
loading D:\work\arthropods\arthropoddescriber2repository\arthropod_describer_py\arthropod_describer\plugins\test_plugin
setting "projects_folder" to D:\work\arthropods\Projects
Traceback (most recent call last):
File "D:\work\arthropods\arthropoddescriber2repository\arthropod_describer_py\arthropod_describer\import_dialog.py", line 477, in _handle_import_txtInput_changed
self.thumbnail_storage = ThumbnailStorage_(self.temp_storage, thumbnail_size=(128, 64))
File "D:\work\arthropods\arthropoddescriber2repository\arthropod_describer_py\arthropod_describer\thumbnail_storage.py", line 31, in __init__
self._load_thumbnails()
File "D:\work\arthropods\arthropoddescriber2repository\arthropod_describer_py\arthropod_describer\thumbnail_storage.py", line 36, in _load_thumbnails
self._generate_thumbnail(img)
File "D:\work\arthropods\arthropoddescriber2repository\arthropod_describer_py\arthropod_describer\thumbnail_storage.py", line 45, in _generate_thumbnail
photo.thumbnail = im.toqimage()
File "C:\Users\Karel\miniconda3\envs\arth\lib\site-packages\PIL\Image.py", line 2605, in toqimage
return ImageQt.toqimage(self)
File "C:\Users\Karel\miniconda3\envs\arth\lib\site-packages\PIL\ImageQt.py", line 204, in toqimage
return ImageQt(im)
File "C:\Users\Karel\miniconda3\envs\arth\lib\site-packages\PIL\ImageQt.py", line 187, in __init__
im_data = _toqclass_helper(im)
File "C:\Users\Karel\miniconda3\envs\arth\lib\site-packages\PIL\ImageQt.py", line 167, in _toqclass_helper
raise ValueError(f"unsupported image mode {repr(im.mode)}")
ValueError: unsupported image mode 'RGBX'
Process finished with exit code 1
Non-debug mode
After selecting one of the above folders for import, the "No photos found" checkbox (that was unchecked and inactive) in the import window becomes active, but stays unchecked and stays on "No photos found". When checked, it changes into "1 photo selected for import", but the whole time, the thumbnail table stays empty.
If you first select a folder with a non-problematic image (like a.png or barbar_10.tif.png), and then browse again for one of the problematic folders, the a.png or barbar_10.tif.png thumbnail stays displayed, together with its values (size etc.).
Not sure what happens if Import/Create is actually clicked in this situation.


