java – 如何从图片中获取纬度和经度信息

前端之家收集整理的这篇文章主要介绍了java – 如何从图片中获取纬度和经度信息前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
如何从设备或SD卡中的图片存储中获取经度和纬度信息?

解决方法

我找到了这个问题的非常简单的解决方案….所以我在这里发布它是为了帮助我有问题的朋友从图片获取Geo位置.
Bundle bundle = getIntent().getExtras();

if(null != bundle)
{
    String filepath = bundle.getString(FILE_PATH_KEY);

    try 
    {
        ExifInterface exif = new ExifInterface(filepath);
        StringBuilder builder = new StringBuilder();

        builder.append("Date & Time: " + getExifTag(exif,ExifInterface.TAG_DATETIME) + "\n\n");
        builder.append("Flash: " + getExifTag(exif,ExifInterface.TAG_FLASH) + "\n");
        builder.append("Focal Length: " + getExifTag(exif,ExifInterface.TAG_FOCAL_LENGTH) + "\n\n");
        builder.append("GPS Datestamp: " + getExifTag(exif,ExifInterface.TAG_FLASH) + "\n");
        builder.append("GPS Latitude: " + getExifTag(exif,ExifInterface.TAG_GPS_LATITUDE) + "\n");
        builder.append("GPS Latitude Ref: " + getExifTag(exif,ExifInterface.TAG_GPS_LATITUDE_REF) + "\n");
        builder.append("GPS Longitude: " + getExifTag(exif,ExifInterface.TAG_GPS_LONGITUDE) + "\n");
        builder.append("GPS Longitude Ref: " + getExifTag(exif,ExifInterface.TAG_GPS_LONGITUDE_REF) + "\n");
        builder.append("GPS Processing Method: " + getExifTag(exif,ExifInterface.TAG_GPS_PROCESSING_METHOD) + "\n");
        builder.append("GPS Timestamp: " + getExifTag(exif,ExifInterface.TAG_GPS_TIMESTAMP) + "\n\n");
        builder.append("Image Length: " + getExifTag(exif,ExifInterface.TAG_IMAGE_LENGTH) + "\n");
        builder.append("Image Width: " + getExifTag(exif,ExifInterface.TAG_IMAGE_WIDTH) + "\n\n");
        builder.append("Camera Make: " + getExifTag(exif,ExifInterface.TAG_MAKE) + "\n");
        builder.append("Camera Model: " + getExifTag(exif,ExifInterface.TAG_MODEL) + "\n");
        builder.append("Camera Orientation: " + getExifTag(exif,ExifInterface.TAG_ORIENTATION) + "\n");
        builder.append("Camera White Balance: " + getExifTag(exif,ExifInterface.TAG_WHITE_BALANCE) + "\n");         

        builder = null;
    }
    catch (IOException e) 
    {
        e.printStackTrace();
    }
}

我们可以在一个构建器字符串中从图片获取所有Exif标记信息.

猜你在找的Java相关文章