0

I'm trying to read the GPSIFD directory of a .tif file, and in particular read GPSLatitude,GPSLongtitude,GPSAltitude and convert them to decimal values.

So far I succeeded to read the GPSIFD, I used ReadExifDirectory to read the GPSIFD directory. Then, I used GetField with a cast to TiffTag, I get back a FieldValue[] where first value is int 3 and second value is byte[12]. It appears to me that the byte[12] array is too small to contain the latitude data, which usually consist of 6 numbers or 3 relational numbers (nominator/dominator)x3.

I used Exif tool and this is the latitude I expect to read:

enter image description here

The byte[] I'm getting is:

enter image description here

The code:

    var gpsIFDTag = image.GetField(TiffTag.GPSIFD);
    if (gpsIFDTag != null)
    {
        int gpsIFDOffset = gpsIFDTag[0].ToInt();
        image.ReadEXIFDirectory(gpsIFDOffset);
        var latitudeByteArr = image.GetField((TiffTag)2)?[1].Value as byte[]; // 2 is the offset to latitude, [0] returns int count of 3 and [1] is the byte array
        if (latitudeByteArr != null)
        {
            // the byte array is of size 12 and I have no idea how to convert it to decimal

        }
    }

0 Answers0