seemoo-lab / opendrop

An open Apple AirDrop implementation written in Python
https://owlink.org
GNU General Public License v3.0
8.49k stars 265 forks source link

In case the image's EXIF does not contain the "Orientation" key #26

Closed sumimakito closed 4 years ago

sumimakito commented 4 years ago

Sometimes if the EXIF data of the image to be sent does not contain the "Orientation" key, a KeyError will be raised.

Traceback (most recent call last):
  File "./bin/opendrop", line 10, in <module>
    sys.exit(main())
  File "./lib/python3.6/site-packages/opendrop/cli.py", line 38, in main
    AirDropCli(sys.argv[1:])
  File "./lib/python3.6/site-packages/opendrop/cli.py", line 87, in __init__
    self.send()
  File "./lib/python3.6/site-packages/opendrop/cli.py", line 160, in send
    if not self.client.send_ask(self.file):
  File "./lib/python3.6/site-packages/opendrop/client.py", line 150, in send_ask
    icon = AirDropUtil.generate_file_icon(f.name)
  File "./lib/python3.6/site-packages/opendrop/util.py", line 180, in generate_file_icon
    orientation = exif['Orientation']
KeyError: 'Orientation'

Fix: I've added an except statement for the KeyError.

Great project! 🍻

Titaniumtown commented 4 years ago

Please push! I have had this issue!

schmittner commented 4 years ago

Can you provide an example file where this happens?

Titaniumtown commented 4 years ago

It's just images taken with digital cameras. ex. Dslrs and webcams

schmittner commented 4 years ago

Was able to reproduce this, thanks for the fix.