星五博客

不加载完整图片就获取图片属性【转帖】

//#import <ImageIO/ImageIO.h>
    //Some path
    NSString* path = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"back-btn.png"];
    NSURL* imageFileURL = [NSURL fileURLWithPath:path];
    CGImageSourceRef imageSource = CGImageSourceCreateWithURL((__bridge CFURLRef)imageFileURL, NULL);
    if(imageSource) {
        NSDictionary* options = @{(NSString*)kCGImageSourceShouldCache:@NO};
        CFDictionaryRef imageProperties = CGImageSourceCopyPropertiesAtIndex(imageSource, 0, (__bridge CFDictionaryRef)options);
        if(imageProperties) {
            NSLog( @"properties: %@", imageProperties);
            CFRelease(imageProperties);
        }
    } else{
        NSLog(@" Error loading image");
    }


IOS