Skip to content

UnboundLocalError: local variable 'has_exif' referenced before assignment #36

Closed
@dzyla

Description

@dzyla

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions