Question GPS in EXIF ?

spanner5351

New member
Joined
Jan 6, 2009
Messages
3
Programming Experience
1-3
Hi guys,

only just signed up here because i have been pulling my hair out trying to find answers all of the internet but to no avail!

As part of a project I am writing a program to be able to add GPS information to jpg pictures. For example to add the latitude and longitude to a photo.

So far i have managed to be able to change the latitude and longitude of jpg photos which already have these GPS field in the EXIF.

However...if i try to add the latitude and longitude information to photos that have never been tagged before i get the following error:

"Property cannot be found." on the following lines of code:

Dim latProp As PropertyItem = photo.GetPropertyItem(2)
Dim longProp As PropertyItem = photo.GetPropertyItem(4)


Ok so this to me means, that this photo does not have the above PropertyItems within it EXIF...

my question is....how do i add these PropertyItems to the file!!!???

any ideas!!?

oh and if i havent explained myself clearly, please let me know so i can clarify as i really do need to answers to this.

Thanks!!
-----
Information - Using Visual Studio 2005 and writing in vb.net
 
image.SetPropertyItem is fine for setting a field which exists. for example if a photo already has GPS data and you want to update it to a new coordinate, that will work.

However, if you try to set this property for a photo that has never had GPS data within it, it will fail and say that this field does not exist.
 
image.SetPropertyItem is fine for setting a field which exists. for example if a photo already has GPS data and you want to update it to a new coordinate, that will work.

However, if you try to set this property for a photo that has never had GPS data within it, it will fail and say that this field does not exist.

That's right , what I want to do is add GPS field within the EXIF.
Pls help me..
 
I'll start you off.

VB.NET:
    Private Function CreatePropertyItem() As PropertyItem
        Dim ci As System.Reflection.ConstructorInfo = GetType(PropertyItem).GetConstructor(BindingFlags.NonPublic Or BindingFlags.Instance Or BindingFlags.Public, Nothing, New Type() {}, Nothing)
        Return DirectCast(ci.Invoke(Nothing), PropertyItem)
    End Function

Now you should be able to program or Google the rest :D
 
I'll start you off.

VB.NET:
    Private Function CreatePropertyItem() As PropertyItem
        Dim ci As System.Reflection.ConstructorInfo = GetType(PropertyItem).GetConstructor(BindingFlags.NonPublic Or BindingFlags.Instance Or BindingFlags.Public, Nothing, New Type() {}, Nothing)
        Return DirectCast(ci.Invoke(Nothing), PropertyItem)
    End Function

Now you should be able to program or Google the rest :D

ok, thanks. I'll try it.
 
Back
Top