Har*_*hah 15 metadata image ios
我想使用ios显示图像元数据.像Aperture,Shutterspeed,曝光补偿,ISO,镜头焦距等元数据.如果有人有想法,请帮助我.
Jon*_*lli 29
CGImageSourceRef source = CGImageSourceCreateWithURL( (CFURLRef) aUrl, NULL);
CGImageSourceRef source = CGImageSourceCreateWithData( (CFDataRef) theData, NULL);
NSDictionary* metadata = (NSDictionary *)CFBridgingRelease(CGImageSourceCopyPropertiesAtIndex(source,0,NULL));
CFRelease(source);
Run Code Online (Sandbox Code Playgroud)
在这里查看字典内容.
Usm*_*sar 10
这是代码,从图像路径获取元数据:
NSData *imagedata = [NSData dataWithContentsOfFile:imagePath];
CGImageSourceRef source = CGImageSourceCreateWithData((CFMutableDataRef)imagedata, NULL);
NSDictionary *metadata = [(NSDictionary *)CGImageSourceCopyPropertiesAtIndex(source,0,NULL)autorelease];
Run Code Online (Sandbox Code Playgroud)
或者,如果使用swift 4.0:
var imagedata = Data(contentsOfFile: imagePath)
var source: CGImageSourceRef = CGImageSourceCreateWithData((imagedata as? CFMutableDataRef), nil)
var metadata = CGImageSourceCopyPropertiesAtIndex(source, 0, nil) as? [AnyHashable: Any]
Run Code Online (Sandbox Code Playgroud)
迅捷 4
static func imageDataProperties(_ imageData: Data) -> NSDictionary? {
if let imageSource = CGImageSourceCreateWithData(imageData as CFData, nil)
{
if let dictionary = CGImageSourceCopyPropertiesAtIndex(imageSource, 0, nil) {
return dictionary
}
}
return nil
}
Run Code Online (Sandbox Code Playgroud)