Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8270835
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T06:41:55+00:00 2026-06-08T06:41:55+00:00

I am having problems converting GPS coordinates to a byte array that can be

  • 0

I am having problems converting GPS coordinates to a byte array that can be stored as EXIF information.

This questions states that EXIF coordinates should be expressed as three rational numbers: degrees/1, minutes/1, seconds/1. I’m having no trouble converting a decimal coordinate to that. For example 42.1234567 is easily converted to 42/1, 7/1, 24/1.

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 ExifWorks, and I’m using it in VB.NET.

The ExifWorks setProperty method takes three things: the EXIF field ID, an array of bytes as data, and the data type. Here’s how I use it:

ew.SetProperty(TagNames.GpsLatitude, byteArrayHere, ExifWorks.ExifDataTypes.UnsignedRational)

I’ve also tried:

ew.SetPropertyString(TagNames.GpsLatitude, "42/1, 7/1, 24/1")

Which also doesn’t work.

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T06:41:56+00:00Added an answer on June 8, 2026 at 6:41 am

    I’ve figured it out. Here’s the solution:

    Private Shared Function intToByteArray(ByVal int As Int32) As Byte()
        ' a necessary wrapper because of the cast to Int32
        Return BitConverter.GetBytes(int)
    End Function
    
    Private Shared Function doubleCoordinateToRationalByteArray(ByVal doubleVal As Double) As Byte()
        Dim temp As Double
    
        temp = Math.Abs(doubleVal)
        Dim degrees = Math.Truncate(temp)
    
        temp = (temp - degrees) * 60
        Dim minutes = Math.Truncate(temp)
    
        temp = (temp - minutes) * 60
        Dim seconds = Math.Truncate(temp)
    
        Dim result(24) As Byte
        Array.Copy(intToByteArray(degrees), 0, result, 0, 4)
        Array.Copy(intToByteArray(1), 0, result, 4, 4)
        Array.Copy(intToByteArray(minutes), 0, result, 8, 4)
        Array.Copy(intToByteArray(1), 0, result, 12, 4)
        Array.Copy(intToByteArray(seconds), 0, result, 16, 4)
        Array.Copy(intToByteArray(1), 0, result, 20, 4)
    
        Return result
    End Function
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I`m having problems converting a char array read from file to an int array.
I have the following SQL that I am having problems converting to HQL. A
I'm having problems converting HTML into regular expressions. I just can't seem to figure
I am having trouble with a stored procedure that is pulling information from the
I'm having problems converting smallint in t-sql to integer in C#. Please can someone
I'm having some problems with converting some JSON and I'm after some help. This
I am having some problems converting string to decimal values with decimal.parse. This is
I am having some problems with converting bytes to gigabytes, I have this code
I'm having problems converting a binary rooted tree to newick format. The full explanation
I'm converting a open-source application from C to Delphi, but I'm having problems converting

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.