- 浏览: 2488576 次
- 性别:
- 来自: 苏州
文章分类
最新评论
-
jsntghf:
peio 写道这个怎么运行?Ruby On Rails的环境搭 ...
多文件上传之uploadify -
peio:
这个怎么运行?
多文件上传之uploadify -
往事如烟1:
我的项目是自己init了一个原始的project,之后将ver ...
React Native热部署之CodePush -
jsntghf:
往事如烟1 写道我按照你的说明进行,发现app退出之后,在进入 ...
React Native热部署之CodePush -
往事如烟1:
我按照你的说明进行,发现app退出之后,在进入不正确,请问是什 ...
React Native热部署之CodePush
首先,将AssetsLibrary.framework、CoreLocation.framework和ImageIO.framework加入到项目中。
PhotoLibViewController.h
#import <UIKit/UIKit.h> #import <AssetsLibrary/AssetsLibrary.h> @interface PhotoLibViewController : UIViewController <UIImagePickerControllerDelegate, UINavigationControllerDelegate> { } - (IBAction)toGetImage:(id)sender; @end
PhotoLibViewController.m
#import "PhotoLibViewController.h" #import "PhotoLibImageInfoController.h" #import "HHLocationManager.h" #import <ImageIO/ImageIO.h> @implementation PhotoLibViewController - (NSMutableDictionary *)updateExif:(CLLocation *)currentLocation{ NSMutableDictionary *locDict = [[NSMutableDictionary alloc] init]; CLLocationDegrees exifLatitude = currentLocation.coordinate.latitude; CLLocationDegrees exifLongitude = currentLocation.coordinate.longitude; [locDict setObject:currentLocation.timestamp forKey:(NSString *)kCGImagePropertyGPSTimeStamp]; if (exifLatitude < 0.0) { exifLatitude = exifLatitude * (-1); [locDict setObject:@"S" forKey:(NSString *)kCGImagePropertyGPSLatitudeRef]; } else { [locDict setObject:@"N" forKey:(NSString *)kCGImagePropertyGPSLatitudeRef]; } [locDict setObject:[NSNumber numberWithFloat:exifLatitude] forKey:(NSString *)kCGImagePropertyGPSLatitude]; if (exifLongitude < 0.0) { exifLongitude = exifLongitude * (-1); [locDict setObject:@"W" forKey:(NSString *)kCGImagePropertyGPSLongitudeRef]; } else { [locDict setObject:@"E" forKey:(NSString *)kCGImagePropertyGPSLongitudeRef]; } [locDict setObject:[NSNumber numberWithFloat:exifLongitude] forKey:(NSString *) kCGImagePropertyGPSLongitude]; return [locDict autorelease]; } - (void)dealloc { [super dealloc]; } #pragma mark - View lifecycle - (void)viewDidLoad { [super viewDidLoad]; } - (void)viewDidUnload { [super viewDidUnload]; } #pragma mark - IBAction - (IBAction)toGetImage:(id)sender { UIButton *button = (UIButton *)sender; UIImagePickerController *iconPickerController = [[UIImagePickerController alloc] init]; if (button.tag == 51) { iconPickerController.sourceType = UIImagePickerControllerSourceTypeSavedPhotosAlbum; } else if (button.tag == 50) { iconPickerController.sourceType = UIImagePickerControllerSourceTypeCamera; iconPickerController.cameraFlashMode = UIImagePickerControllerCameraFlashModeAuto; iconPickerController.showsCameraControls = YES; } iconPickerController.delegate = self; [self presentModalViewController:iconPickerController animated:YES]; [[HHLocationManager shared] startStandardUpdates]; [iconPickerController release]; } #pragma mark UIImagePickerControllerDelegate - (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info { NSString *mediaType = [info objectForKey:UIImagePickerControllerMediaType]; if (![mediaType isEqualToString:@"public.image"]) { return; } NSURL *imageURL = [info objectForKey:UIImagePickerControllerReferenceURL]; ALAssetsLibrary *library = [[ALAssetsLibrary alloc] init]; CGImageRef imageRef = [[info objectForKey:UIImagePickerControllerOriginalImage] CGImage]; typedef void (^ALAssetsLibraryAssetForURLResultBlock)(ALAsset *asset); typedef void (^ALAssetsLibraryAccessFailureBlock)(NSError *error); typedef void (^ALAssetsLibraryWriteImageCompletionBlock)(NSURL *assetURL, NSError *error); ALAssetsLibraryAssetForURLResultBlock resultblock = ^(ALAsset *myasset) { ALAssetRepresentation *rep = [myasset defaultRepresentation]; CGImageRef iref = [rep fullResolutionImage]; PhotoLibImageInfoController *imageInfo = [[PhotoLibImageInfoController alloc] initWithNibName:@"PhotoLibImageInfoController" bundle:nil]; imageInfo.image = [UIImage imageWithCGImage:iref]; imageInfo.imageInfo = [rep metadata]; NSLog(@"ALAssetRepresentation: %@", [rep metadata]); [self.navigationController pushViewController:imageInfo animated:YES]; [imageInfo release]; [library release]; }; ALAssetsLibraryAccessFailureBlock failureblock = ^(NSError *myerror) { NSLog(@"Error, cant get image - %@", [myerror localizedDescription]); [library release]; }; ALAssetsLibraryWriteImageCompletionBlock completionblock = ^(NSURL *assetURL, NSError *error) { [library assetForURL:assetURL resultBlock:resultblock failureBlock:failureblock]; NSLog(@"Error, cant save image - %@", [error localizedDescription]); }; if (picker.sourceType == UIImagePickerControllerSourceTypeCamera) { NSDictionary *gpsDict = [self updateExif:[[HHLocationManager shared] thisLocation]]; NSMutableDictionary *imageMetaData = [NSMutableDictionary dictionary]; [imageMetaData setObject:gpsDict forKey:(NSString *)kCGImagePropertyGPSDictionary]; [library writeImageToSavedPhotosAlbum:imageRef metadata:imageMetaData completionBlock:completionblock]; } else { [library assetForURL:imageURL resultBlock:resultblock failureBlock:failureblock]; } [picker performSelector:@selector(dismissModalViewControllerAnimated:) withObject:[NSNumber numberWithBool:YES] afterDelay:1.0]; } @end
PhotoLibImageInfoController.h
#import <UIKit/UIKit.h> @interface PhotoLibImageInfoController : UIViewController { } @property (nonatomic, retain) IBOutlet UIImageView *imageView; @property (nonatomic, retain) IBOutlet UITextView *info; @property (nonatomic, retain) NSDictionary *imageInfo; @property (nonatomic, retain) UIImage *image; @end
PhotoLibImageInfoController.m
#import "PhotoLibImageInfoController.h" @implementation PhotoLibImageInfoController @synthesize imageView, info, imageInfo, image; - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil { self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; if (self) { imageInfo = [[NSDictionary alloc] init]; image = [[UIImage alloc] init]; } return self; } - (void)dealloc { [image release]; [imageInfo release]; [imageView release]; [info release]; [super dealloc]; } #pragma mark - View lifecycle - (void)viewDidLoad { [super viewDidLoad]; } - (void)viewDidAppear:(BOOL)animated { [super viewDidAppear:animated]; if (image) self.imageView.image = image; if (imageInfo) self.info.text = [imageInfo description]; } - (void)viewDidUnload { [super viewDidUnload]; } @end
示例输出:
{ ColorModel = RGB; DPIHeight = 100; DPIWidth = 100; Depth = 8; PixelHeight = 120; PixelWidth = 120; "{Exif}" = { ColorSpace = 1; ComponentsConfiguration = ( 1, 2, 3, 0 ); ExifVersion = ( 2, 2, 1 ); FlashPixVersion = ( 1, 0 ); PixelXDimension = 120; PixelYDimension = 120; SceneCaptureType = 0; }; "{GPS}" = { Latitude = "31.2795"; LatitudeRef = N; Longitude = "120.7431666666667"; LongitudeRef = E; }; "{TIFF}" = { ResolutionUnit = 2; XResolution = 100; YResolution = 100; "_YCbCrPositioning" = 1; }; }
- PhotoLib.zip (57.3 KB)
- 下载次数: 39
发表评论
-
Error watching file for changes: EMFILE
2016-12-15 11:57 1255执行npm start后报错: Error watc ... -
CocoaPods升级1.1.1报错
2016-12-15 08:39 756ERROR: While executing gem .. ... -
Visual Studio Code运行React Native报错
2016-06-13 09:43 1579React Native:0.27.2 React:15 ... -
React Native 0.27.2编译报错this._nativeModule.addListener is not a function
2016-06-12 15:21 3812React Native:0.27.2 React:15 ... -
Unable to resolve module ReactDefaultPerf from
2016-06-02 13:04 2747package.json信息如下: "reac ... -
React Native 0.26.2编译报错Undefined symbols for architecture x86_64
2016-05-26 11:15 1962React Native:0.26.2 React:15. ... -
Failed to update auto layout status: Failed to load designables from path (null)
2016-04-05 22:11 1680确保CocoaPods是0.36.1以上版本,然后在podf ... -
集成微信支付出现Undefined symbols for architecture x86_64错误
2016-03-21 13:22 1700Undefined symbols for architec ... -
React Native热部署之CodePush
2016-01-10 22:27 6158本文使用的环境是Mac OS 10.11.1、Xcode ... -
浅谈React Native中的FlexBox布局
2015-11-17 18:38 4284React Native通过一个基于FlexBox的布局引 ... -
React Native之构建一个简单的列表页
2015-10-23 14:45 2118本文中我们将创建一个简单的电影应用,这个应用将从Rotten ... -
React Native之环境搭建
2015-10-20 16:30 1408本文使用的环境是Mac O ... -
获取图片属性的方法
2015-10-18 20:43 3108很多时候我们需要获 ... -
NSCache的下标用法
2015-09-18 00:19 1181NSCache类和NSDictionary类很相似,也提供 ... -
如何给category添加属性
2015-08-16 10:41 653主要是使用了runtime中的associative机制。 ... -
UITableView的两种重用Cell方法的区别
2015-08-10 13:07 16087UITableView中有两种重用Cell的方法: - ... -
SDImageCache.m报错Unused variable 'fileName'
2015-08-04 21:56 1147GCC手册中的相关解释: unused:This att ... -
Swift调用Objective-C
2015-07-13 23:33 1192Swift调用Objective-C需要一个名为<工程 ... -
使用GCD实现倒计时
2015-07-24 21:47 1059__block int timeout = 60; // ... -
导航栏加分割线的实现
2015-07-01 22:00 1712self.view.backgroundColor = [U ...
相关推荐
摘要:本文讲述了使用 C# 读取图片的 EXIF 信息的方法,包括读取照片 ISO 感光度、曝光时间、快门速度、闪光灯、曝光模式、照片宽度、高度、f 值、曝光程序、光谱感知、EXIF 版本、色彩设置、压缩比率、光圈值、亮度...
VB IPTC信息读取 VB EXIF信息读取
用C++写的读取图片EXIF信息的类,封装好的,可以直接使用
delphi xe 读取照片缩略图及EXIF信息源码,测试通过。
主要介绍了PHP中读取照片exif信息的方法,本文从什么是exif信息开始讲解,使用PHP需要什么扩展、及它的安装方法和使用代码示例等,需要的朋友可以参考下
插件描述:用于论坛上传JPG... 主要功能: 1、上传文件时即可读取Exif信息并写入数据库,减少帖子显示时再读取Exif信息导致的页面拖延 2、支持论坛水印开启后的Exif信息显示 3、支持同时显示以往上传的文件显示Exif信息
Delphi7写的读取JPEG文件Exif信息的类(含中文注释及Exif v2.3官方文档,含显示TIF格式的GraphicEx库) 支持JPEG格式的缩略图读取,TIF格式的暂时未遇到,不知正确与否。 记录为摩托罗拉CPU格式的Exif信息暂时未遇到...
读取数码照片EXIF信息源码
照片自动分类归并,自动读取照片文件的exif信息.rar
纯 python 写的,批量读取照片的 Exif 信息(重点是GPS坐标)保存到 csv, xlsx 文件中的小程序,图形界面,操作简单。读取几千张照片,几分钟的事情。并且借鉴网友的算法尝试做了不同坐标系的转换。 下载压缩包,...
public class EXIF { #region -- Class level members -- // Class level members. private Image _picture; #endregion #region -- Constructors -- // Constructors. /// /// This is default ...
vb 类模块,可以读取照片EXIF信息,照片位置,包含的GPS经纬度坐标等等。源码例子是读取GPS坐标的。
使用方法 加上一个用到的jar包metadata-extractor-2.3.1.jar
通过导入一张图片,调用封装好的函数尽心解析图片的信息,可以提取里面全部信息,例如经纬度,时间,相机的信息,光照,高度,等等,你需要按照一下步骤进行了 Cexif exif; // EXIFINFO pexif=(EXIFINFO *)malloc...
一个C++实现的读取照片的exif信息,用Qt写了个简单的界面
EXIF(Exchangeable image file format)是可交换图像文件的缩写,是专门为数码相机的照片设定的,可以记录数码照片的属性信息和拍摄数据。该代码读取该信息,供用户或编程使用。
Andriod下读取图片Exif信息Demo,详细参见博客:http://www.cnblogs.com/plokmju/p/android_exif.html
测试可用代码