4

我想知道inspector中一张图片的信息。有没有办法从objective-c中检索该信息。

在此处输入图像描述

上面的屏幕截图是检查器窗口的示例。我想使用目标 c 获取该窗口的信息。谢谢 !!

4

1 回答 1

5

NSImage虽然您可以使用or获得大多数这些属性CGImage,但我会看一下 ImageIO.framework。
它的优点是可以读取多种图像格式的标头,而无需将整个图像读入 RAM。
Apple 提供了一个示例应用程序,可以完全满足您的需求:ImageApp

有关使用 ImageIO 获取元数据的详细信息,也可以在 Image I/O Programming Guide 的“Displaying Image Properties”部分找到。

要获取文件元数据,您可以使用NSFileManager's attributesOfItemAtPath::

NSError* error = nil;
NSDictionary* fileAttributeDict = [[NSFileManager defaultManager] attributesOfItemAtPath:imageFilePath error:&error];
NSLog(@"creation date:%@\nmodification date:%@", fileAttributeDict.fileCreationDate, fileAttributeDict.fileModificationDate);
于 2013-05-14T06:21:52.607 回答