IOS获取网络图片属性
2013-04-17 16:42
344 查看
- (CGSize)getImageSizeWithURL:(NSURL *)url { CGImageSourceRef imageSource = CGImageSourceCreateWithURL((CFURLRef)url, NULL); CGFloat width = 0.0f, height = 0.0f; if (imageSource) { CFDictionaryRef imageProperties = CGImageSourceCopyPropertiesAtIndex(imageSource, 0, NULL); if (imageProperties != NULL) { CFNumberRef widthNum = CFDictionaryGetValue(imageProperties, kCGImagePropertyPixelWidth); if (widthNum != NULL) { CFNumberGetValue(widthNum, kCFNumberFloatType, &width); } CFNumberRef heightNum = CFDictionaryGetValue(imageProperties, kCGImagePropertyPixelHeight); if (heightNum != NULL) { CFNumberGetValue(heightNum, kCFNumberFloatType, &height); } CFRelease(imageProperties); } CFRelease(imageSource); NSLog(@"Image dimensions: %.0f x %.0f px", width, height); } return CGSizeMake(width, height); }
#import <ImageIO/ImageIO.h>
导入 ImageIO框架
相关文章推荐
- iOS 异步加载网络图片,获取图片真实尺寸
- IOS 获取网络地址的html字符串 本地获取网络图片
- iOS开发-进阶:通过URL地址,从网络上获取图片
- IOS获取网络图片的方法
- ios通过URL地址,从网络上获取图片
- IOS -- 获取本地图片和网络图片的大小size
- IOS -- 获取本地图片和网络图片的大小size
- ios 从网络上获取图片并在UIImageView中显示
- iOS如何获取网络图片(二)
- ios获取网络图片的尺寸
- iOS 通过网络请求获取图片的下载歌曲
- iOS下载图片之前获取网络图片尺寸的失败尝试
- 检测SDWebImage有没有缓存图片 IOS 获取网络图片大小
- IOS网络第五天 AFN-02-文件上传,底部弹出窗体,拍照和相册获取图片上传
- 检测SDWebImage有没有缓存图片 IOS 获取网络图片大小
- ios开发-获取网络图片
- iOS-UIImageView获取网络图片
- ios通过URL获取网络图片的原始大小
- IOS -- 获取本地图片和网络图片的大小size
- iOS--把网络获取图片进行不变形缩放