hMatoba / Piexif

Exif manipulation with pure python script.
MIT License
367 stars 81 forks source link

GPS conversion error with Python Fraction for rational 64 output #106

Open apiszcz opened 4 years ago

apiszcz commented 4 years ago

This line in in _dump.py new_value += (struct.pack(">L", num) +

is failing with large rational integer outputs of Python Fraction Fraction(2476979795053773, 2251799813685248)

Is there a better way to generate the rational fraction the GPS lat, lon require?

sthi0460 commented 3 years ago

I was running into this issue a few days ago as well. I realized that I could not use rational numbers representing geo-coords in the decimal degrees format for a couple of reasons. I converted decimal degrees into three separate rational numbers for the hours, minutes, and seconds. The rational numbers for hours and minutes are all of the form "(some_integer, 1)," while the seconds rational numbers are "(some_integer, some_integer)." I am finding with the accuracy required for my project, all "seconds" rational numbers can be represented by 32-bit numbers. Looking at the EXIF standard documentation, GPS coordinated are required to be in the (hours_rational, minutes_rational, seconds_rational) format anyway, with all numbers 32-bit. It is possible that Piexif is written to accept 64-bit decimal degree coordinates and I was encountering another error entirely. But, I was able to successfully add lat/lon to images using the above method.