我在从图像(包含地理位置详细信息)获取纬度和经度数据时遇到问题。我已经导入了 EXIF 框架,我正在使用以下代码来实现这一点:
NSData *jpegData = [UIImageJPEGRepresentation(image, 0.5) base64String];
EXFJpeg* jpegScanner = [[EXFJpeg alloc] init];
[jpegScanner scanImageData: jpegData];
EXFMetaData* exifData = jpegScanner.exifMetaData;
id latitudeValue = [exifData tagValue:[NSNumber numberWithInt:EXIF_GPSLatitude]];
id longitudeValue = [exifData tagValue:[NSNumber numberWithInt:EXIF_GPSLongitude]];
NSLog(@"Longitude: %@ Longitude: %@", latitudeValue, longitudeValue);
但是它返回纬度和经度的 NULL 值,谁能告诉我我在上面的代码中做错了什么?请帮帮我。提前致谢!!
Best Answer-推荐答案 strong>
您可以使用 alasset框架。
ALAssetsLibrary *assetsLibrary = [[ALAssetsLibrary alloc]init];
[assetsLibrary assetForURL:photoUrl resultBlock:resultBlock failureBlock:nil];
ALAssetsLibraryAssetForURLResultBlock resultBlock = ^(ALAsset *photoAsset) {
CLLocation *location = [photoAsset valueForProperty:ALAssetPropertyLocation];
NSMutableDictionary *exifDataDict = [[NSMutableDictionary alloc] init];
if (location != nil) {
[exifDataDict setObject:[NSNumber numberWithDouble:location.coordinate.latitude] forKey"latitude"];
[exifDataDict setObject:[NSNumber numberWithDouble:location.coordinate.longitude] forKey"longitude"];
}
}
关于ios - 从图像Objective c中提取经纬度,我们在Stack Overflow上找到一个类似的问题:
https://stackoverflow.com/questions/18018244/
|