title: Converting Lat / Long GPS coordinates to an EXIF Rational byte array
body: <p>I am having problems converting GPS coordinates to a byte array that can be stored as EXIF information.</p>
  
  <p><a href="https://stackoverflow.com/questions/5280479/how-to-save-gps-coordinates-in-exif-data-on-android">This questions</a> states that EXIF coordinates should be expressed as three rational numbers: <code>degrees/1, minutes/1, seconds/1</code>. I'm having no trouble converting a decimal coordinate to that. For example <code>42.1234567</code> is easily converted to <code>42/1, 7/1, 24/1</code>.</p>
  
  <p>My problem is that I don't understand how to represent this as a byte array when I write it to the image EXIF information. The library that I'm using is called <a href="http://www.codeproject.com/Articles/4956/The-ExifWorks-class" rel="nofollow noreferrer">ExifWorks</a>, and I'm using it in VB.NET.</p>
  
  <p>The ExifWorks <code>setProperty</code> method takes three things: the EXIF field ID, an array of bytes as data, and the data type. Here's how I use it:</p>
  
  <pre><code>ew.SetProperty(TagNames.GpsLatitude, byteArrayHere, ExifWorks.ExifDataTypes.UnsignedRational)
  </code></pre>
  
  <p>I've also tried:</p>
  
  <pre><code>ew.SetPropertyString(TagNames.GpsLatitude, "42/1, 7/1, 24/1")
  </code></pre>
  
  <p>Which also doesn't work.</p>
  
  <p>So, my question is, how do I convert my degree-minute-second coordinate into a byte array? Everything I've tried thus far ends up as invalid EXIF information, and doesn't work. A general solution is fine... doesn't necessarily have to work in VB.net.</p>