Uploaded image for project: 'Commons Imaging'
  1. Commons Imaging
  2. IMAGING-285

Decoding of Rational Numbers broken when large values present

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.0-alpha2
    • 1.0-alpha3
    • imaging.common.*
    • None
    • Important

    Description

      Decoding Lat/Long EXIF data from JPEGs does not work for some values.  I have attached a file where the conversion fails.  I used the getLatitudeAsDegreesNorth and getLongitudeAsDegreesEast methods from the TiffImageMetaData.GPSInfo class.  The values are close, but seemingly off by a few miles.

      I've traced the source and I believe the issue is with how the RationalNumber class uses two 32-bit signed integers for the numerator and denominator.  The definition of a RATIONAL data type uses 32-bit unsigned numbers.  It seems as if the RationalNumber class already expects this as it has a non-public static method called factoryMethod to create a RationalNumber from two 64-bit numbers.

      This error is introduced in the ByteConversions class, specifically the toRational method where it uses the regular RationalNumber constructor and thus ensures any rational numbers that have numerator or denominator greater than the max signed 32-bit value will produce invalid values.

      I am attaching a JPEG that has this problem.  I had to crop it to reduce the size, but the EXIF data was preserved.

      The EXIF GPS data contained in the JPEG is:

      GpsLatitudeRef: "N"

      GpsLatitude: 38, 1, 36, 1, 4120083230, 70000000

      GpsLongitudeRef: "W"

      GpsLongitude: 90, 1, 12, 1, 2379156648, 70000000

      According to the properties of the image (right-clicking on Windows 10), the L/L of the image is:

      Latitude: 38: 36: 58.85833....

      Longitude: 90: 12: 33.98795... (Windows doesn't show E/W)

      These values convert to:

      38.616349536627

      -90.2094410978095

      When I use the getLatitudeAsDegreesNorth  and getLongitudeAsDegreesEast methods, I get the following values:

      38.59930601561111

      -90.19239757679365

       

      Attachments

        1. DJI_0267 cropped.JPG
          489 kB
          John Andrade

        Issue Links

          Activity

            People

              kinow Bruno P. Kinoshita
              Droidatopia John Andrade
              Votes:
              1 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - 1h Original Estimate - 1h
                  1h
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 4h
                  4h