We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

How to extract Longitude- Latitude- Altitude from image .JPG/.JPEG


I want to ask you, why the result doesnt appear when execute the code for extracting Longitude, Latitude, Altitude from the image.

Here is my code :

using (JpegImage image = (JpegImage)Image.Load(dataDir + “img3.jpg”))
JpegExifData exifData = image.ExifData;
Console.WriteLine("Camera Owner Name: " + exifData.CameraOwnerName);
Console.WriteLine("Aperture Value: " + exifData.ApertureValue);
Console.WriteLine("Orientation: " + exifData.Orientation);
Console.WriteLine("Focal Length: " + exifData.FocalLength);
Console.WriteLine("Compression: " + exifData.Compression);
Console.WriteLine("GPS : " + exifData.GPSVersionID);
Console.WriteLine("Version : " + System.Text.Encoding.UTF8.GetString(exifData.ExifVersion));
Console.WriteLine("Altitude : " + exifData.GPSAltitude);
Console.WriteLine("Longitude : " + exifData.GPSLongitude);
Console.WriteLine("Latitude : " + exifData.GPSLatitude);

The result is attached here.

Thanks in advance.


Thanks for showing interest in Aspose.Imaging.

I have worked with sample code shared by you and like to share that the image position coordinates are stored inside TifRational array holding information in the form of degree, minuets and seconds. Please try using following sample code on your end to serve the purpose. I hope the shared information will be helpful.

Aspose.Imaging.FileFormats.Tiff.TiffRational [] tifLong = exifData.GPSLongitude;
Aspose.Imaging.FileFormats.Tiff.TiffRational [] tifLat = exifData.GPSLatitude;
Console.WriteLine(String.Format("Latitude : {0}° {1}' {2}\"", tifLat[0].Value, tifLat[1].Value, tifLat[2].Value));
Console.WriteLine(String.Format("Longitude : {0}° {1}'
{2}\"", tifLong[0].Value, tifLong[1].Value, tifLong[2].Value));

Many Thanks,

Hi Mudassir,

I have try your code and so glad it works. Thank you so much. I appreciate it.