optimize-images
optimize-images copied to clipboard
UnboundLocalError: local variable 'has_exif' referenced before assignment
Describe the bug A clear and concise description of what the bug is.
I have a folder that have EXIF and non-exif photos. While running, this error happens:
optimize-images --keep-exif folder/
oncurrent.futures.process._RemoteTraceback:
"""
Traceback (most recent call last):
File "/mnt/f/linux/miniconda3/lib/python3.9/concurrent/futures/process.py", line 243, in _process_worker
r = call_item.fn(*call_item.args, **call_item.kwargs)
File "/mnt/f/linux/miniconda3/lib/python3.9/concurrent/futures/process.py", line 202, in _process_chunk
return [fn(*args) for args in chunk]
File "/mnt/f/linux/miniconda3/lib/python3.9/concurrent/futures/process.py", line 202, in <listcomp>
return [fn(*args) for args in chunk]
File "/mnt/f/linux/miniconda3/lib/python3.9/site-packages/optimize_images/do_optimization.py", line 34, in do_optimization
return optimize_jpg(task)
File "/mnt/f/linux/miniconda3/lib/python3.9/site-packages/optimize_images/img_optimize_jpg.py", line 101, in optimize_jpg
has_exif)
UnboundLocalError: local variable 'has_exif' referenced before assignment
"""
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/mnt/f/linux/miniconda3/bin/optimize-images", line 8, in <module>
sys.exit(main())
File "/mnt/f/linux/miniconda3/lib/python3.9/site-packages/optimize_images/__main__.py", line 154, in main
optimize_batch(*args)
File "/mnt/f/linux/miniconda3/lib/python3.9/site-packages/optimize_images/__main__.py", line 108, in optimize_batch
for result in executor.map(do_optimization, tasks):
File "/mnt/f/linux/miniconda3/lib/python3.9/concurrent/futures/process.py", line 559, in _chain_from_iterable_of_lists
for element in iterable:
File "/mnt/f/linux/miniconda3/lib/python3.9/concurrent/futures/_base.py", line 600, in result_iterator
yield fs.pop().result()
File "/mnt/f/linux/miniconda3/lib/python3.9/concurrent/futures/_base.py", line 440, in result
return self.__get_result()
File "/mnt/f/linux/miniconda3/lib/python3.9/concurrent/futures/_base.py", line 389, in __get_result
raise self._exception
UnboundLocalError: local variable 'has_exif' referenced before assignment
Screenshots If applicable, add screenshots or traceback from console (please redact any confidential info) to help explain your problem.
Desktop (please complete the following information): WSL2, the latest optimize-images, works without --keep-exif
Same thing. Windows 11 WSL2, latest Docker
I could not reproduce the issue here, but I found a typo that could cause that bug (dcc53972). Could you please try again using the current version from GitHub and the same set of images?
I bumped into this issue with version v.1.5.0
.
Could you please try again using the current version from GitHub and the same set of images?
I switched to the latest code on GitHub and the issue has gone. I think the problem was fixed with https://github.com/victordomingos/optimize-images/commit/dcc53972389a4cc91a98e43a458962911d7c5627 . Thanks!
It'd be great if the new release is made :)
Thank you for you feedback. I will try to publish a new release to PyPI in a few days.