读取照片的Exif信息,这篇文章则是使用了ImageIO类来获取照片的信息


前段时间写了一篇文章:读取照片的Exif信息,这篇文章则是使用了ImageIO类来获取照片的信息。

 

首先将ImageIO.framework导入项目中,然后导入头文件:

 

Ios代码   收藏代码
  1. #import <ImageIO/ImageIO.h>  

 

示例:

 

Ios代码   收藏代码
  1. NSURL *modelURL = [[NSBundle mainBundle] URLForResource:@"rails.png" withExtension:nil];  
  2. CGImageSourceRef myImageSource = CGImageSourceCreateWithURL((CFURLRef)modelURL, NULL);  
  3. CFDictionaryRef imagePropertiesDictionary = CGImageSourceCopyPropertiesAtIndex(myImageSource,0, NULL);  
  4. CFNumberRef imageWidth = (CFNumberRef)CFDictionaryGetValue(imagePropertiesDictionary, kCGImagePropertyPixelWidth);  
  5. CFNumberRef imageHeight = (CFNumberRef)CFDictionaryGetValue(imagePropertiesDictionary, kCGImagePropertyPixelHeight);  
  6.   
  7. NSLog(@"%@", imagePropertiesDictionary);  
  8.   
  9. int w = 0;  
  10. int h = 0;  
  11.   
  12. CFNumberGetValue(imageWidth, kCFNumberIntType, &w);  
  13. CFNumberGetValue(imageHeight, kCFNumberIntType, &h);  
  14.   
  15. CFRelease(imagePropertiesDictionary);  
  16. CFRelease(myImageSource);  
  17.   
  18. printf("Image Width: %d\n", w);  
  19. printf("Image Height: %d", h);  

 

示例输出:

 

Ios代码   收藏代码
  1. {  
  2.     ColorModel = RGB;  
  3.     Depth = 8;  
  4.     HasAlpha = 1;  
  5.     PixelHeight = 64;  
  6.     PixelWidth = 50;  
  7.     "{PNG}" =     {  
  8.         InterlaceType = 0;  
  9.         Software = "Adobe ImageReady";  
  10.     };  
  11. }  
  12. Image Width: 50  
  13. Image Height: 64  
 


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值