iOS ImageIO框架詳解(獲取圖片Exif信息及修改GPS等屬性)

一、引言

ImageIO框架提供了讀取與寫入圖片數(shù)據(jù)的基本方法,使用它可以直接獲取到圖片文件的內(nèi)容數(shù)據(jù),ImageIO框架中包含6個(gè)頭文件,其中完成主要功能的是前兩個(gè)頭文件中定義的方法:

1.CGImageSource.h:負(fù)責(zé)讀取圖片數(shù)據(jù)。

2.CGImageDestination.h:負(fù)責(zé)寫入圖片數(shù)據(jù)。

3.CGImageMetadata.h:圖片文件元數(shù)據(jù)類。

4.CGImageProperties:定義了框架中使用的字符串常量和宏。

5.ImageIOBase.h:預(yù)處理邏輯,無需關(guān)心。

二、CGImageSource詳解

CGImageSource類的主要作用是用來讀取圖片數(shù)據(jù),在平時(shí)開發(fā)中,關(guān)于圖片我們使用的最多的可能是UIImage類,UIImage是iOS系統(tǒng)UI系統(tǒng)中用于構(gòu)建圖像對(duì)象的類,但是其中只有圖像數(shù)據(jù),實(shí)際上一個(gè)圖片文件中存儲(chǔ)的除了圖片數(shù)據(jù)外,還有一些地理位置、設(shè)備類型、時(shí)間等信息,除此之外,一個(gè)圖片文件中可能存儲(chǔ)的也不只一張圖像(例如gif文件)。CGImageSource就是這樣的一個(gè)抽象圖片數(shù)據(jù)示例,從其中可以獲取到我們所關(guān)心的所有數(shù)據(jù)。

讀取圖片文件數(shù)據(jù),并將其展示在視圖的簡單代碼示例如下:

//獲取圖片文件路徑
NSString * path = [[NSBundle mainBundle]pathForResource:@"timg" ofType:@"jpeg"];
NSURL * url = [NSURL fileURLWithPath:path];
CGImageRef myImage = NULL;
CGImageSourceRef myImageSource;
//通過文件路徑創(chuàng)建CGImageSource對(duì)象
myImageSource = CGImageSourceCreateWithURL((CFURLRef)url, NULL);
//獲取第一張圖片
myImage = CGImageSourceCreateImageAtIndex(myImageSource,
                                          0,
                                          NULL);
CFRelease(myImageSource);
UIImageView * image = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 200, 200)];
image.image = [UIImage imageWithCGImage:myImage];
[self.view addSubview:image];

上面的示例代碼采用的是本地的一個(gè)素材文件,當(dāng)然通過網(wǎng)絡(luò)圖片鏈接也是可以創(chuàng)建CGImageSource獨(dú)享的。除了通過URL鏈接的方式創(chuàng)建對(duì)象,ImageIO框架中還提供了兩種方法,解析如下:

//通過數(shù)據(jù)提供器創(chuàng)建CGImageSource對(duì)象
/*
CGDataProviderRef是CoreGraphics框架中的一個(gè)數(shù)據(jù)讀取類,其也可以通過Data數(shù)據(jù),URL和文件名來創(chuàng)建
*/
CGImageSourceRef __nullable CGImageSourceCreateWithDataProvider(CGDataProviderRef __nonnull provider, CFDictionaryRef __nullable options);
//通過Data數(shù)據(jù)創(chuàng)建CGImageSource對(duì)象
CGImageSourceRef __nullable CGImageSourceCreateWithData(CFDataRef __nonnull data, CFDictionaryRef __nullable options);

需要注意,上面所提到的所有創(chuàng)建CGImageSource的方法中都可以傳入一個(gè)CFDictionaryRef類型的字典,可以配置的鍵值意義如下:

/*
設(shè)置一個(gè)預(yù)期的圖片文件格式,需要設(shè)置為字符串類型的值
*/
const CFStringRef kCGImageSourceTypeIdentifierHint;
/*
設(shè)置是否以解碼的方式讀取圖片數(shù)據(jù) 默認(rèn)為kCFBooleanTrue
如果設(shè)置為true,在讀取數(shù)據(jù)時(shí)就進(jìn)行解碼 如果為false 則在渲染時(shí)才進(jìn)行解碼
*/
const CFStringRef kCGImageSourceShouldCache;
/*
返回CGImage對(duì)象時(shí)是否允許使用浮點(diǎn)值 默認(rèn)為kCFBooleanFalse
*/
const CFStringRef kCGImageSourceShouldAllowFloa;
/*
設(shè)置如果不存在縮略圖則創(chuàng)建一個(gè)縮略圖,縮略圖的尺寸受開發(fā)者設(shè)置影響,如果不設(shè)置尺寸極限,則為圖片本身大小
默認(rèn)為kCFBooleanFalse
*/
const CFStringRef kCGImageSourceCreateThumbnailFromImageIfAbsent;
/*
設(shè)置是否創(chuàng)建縮略圖,無論原圖像有沒有包含縮略圖kCFBooleanFalse
*/
const CFStringRef kCGImageSourceCreateThumbnailFromImageAlways;
/*
設(shè)置縮略圖的寬高尺寸 需要設(shè)置為CFNumber值
*/
const CFStringRef kCGImageSourceThumbnailMaxPixelSize;
/*
設(shè)置縮略圖是否進(jìn)行Transfrom變換
*/
const CFStringRef kCGImageSourceCreateThumbnailWithTransform;

CGImageSource類中其他方法解析如下:

//獲取CGImageSource類在CoreFundation框架中的id
CFTypeID CGImageSourceGetTypeID (void);
//獲取所支持的圖片格式數(shù)組
CFArrayRef __nonnull CGImageSourceCopyTypeIdentifiers(void);
//獲取CGImageSource對(duì)象的圖片格式
CFStringRef __nullable CGImageSourceGetType(CGImageSourceRef __nonnull isrc);
//獲取CGImageSource中的圖片張數(shù) 不包括縮略圖
size_t CGImageSourceGetCount(CGImageSourceRef __nonnull isrc);
//獲取CGImageSource的文件信息
/*
字典參數(shù)可配置的鍵值對(duì)與創(chuàng)建CGImageSource所傳參數(shù)意義一致
返回的字典中的鍵值意義后面介紹
*/
CFDictionaryRef __nullable CGImageSourceCopyProperties(CGImageSourceRef __nonnull isrc, CFDictionaryRef __nullable options);
//獲取CGImageSource中某個(gè)圖像的附加數(shù)據(jù)
/*
index參數(shù)設(shè)置獲取第幾張圖像 options參數(shù)可配置的鍵值對(duì)與創(chuàng)建CGImageSource所傳參數(shù)意義一致
返回的字典中的鍵值意義后面介紹
*/
CFDictionaryRef __nullable CGImageSourceCopyPropertiesAtIndex(CGImageSourceRef __nonnull isrc, size_t index, CFDictionaryRef __nullable options);
//獲取圖片的元數(shù)據(jù)信息 CGImageMetadataRef類是圖像原數(shù)據(jù)的抽象
CGImageMetadataRef __nullable CGImageSourceCopyMetadataAtIndex (CGImageSourceRef __nonnull isrc, size_t index, CFDictionaryRef __nullable options);
//獲取CGImageSource中的圖片數(shù)據(jù)
CGImageRef __nullable CGImageSourceCreateImageAtIndex(CGImageSourceRef __nonnull isrc, size_t index, CFDictionaryRef __nullable options);
//刪除一個(gè)指定索引圖像的緩存
void CGImageSourceRemoveCacheAtIndex(CGImageSourceRef __nonnull isrc, size_t index);
//獲取某一幀圖片的縮略圖
CGImageRef __nullable CGImageSourceCreateThumbnailAtIndex(CGImageSourceRef __nonnull isrc, size_t index, CFDictionaryRef __nullable options);
//創(chuàng)建一個(gè)空的CGImageSource容器,逐步加載大圖片
CGImageSourceRef __nonnull CGImageSourceCreateIncremental(CFDictionaryRef __nullable options);
//使用新的數(shù)據(jù)更新CGImageSource容器
void CGImageSourceUpdateData(CGImageSourceRef __nonnull isrc, CFDataRef __nonnull data, bool final);
//更新數(shù)據(jù)提供器來填充CGImageSource容器
void CGImageSourceUpdateDataProvider(CGImageSourceRef __nonnull isrc, CGDataProviderRef __nonnull provider, bool final);
//獲取當(dāng)前CGImageSource的狀態(tài)
/*
CGImageSourceStatus枚舉意義:
typedef CF_ENUM(int32_t, CGImageSourceStatus) {
    kCGImageStatusUnexpectedEOF = -5, //文件結(jié)尾出錯(cuò)
    kCGImageStatusInvalidData = -4,   //數(shù)據(jù)無效
    kCGImageStatusUnknownType = -3,   //未知的圖片類型
    kCGImageStatusReadingHeader = -2, //讀標(biāo)題過程中
    kCGImageStatusIncomplete = -1,    //操作不完整
    kCGImageStatusComplete = 0        //操作完整
};
*/
CGImageSourceStatus CGImageSourceGetStatus(CGImageSourceRef __nonnull isrc);
//同上,獲取某一個(gè)圖片的狀態(tài)
CGImageSourceStatus CGImageSourceGetStatusAtIndex(CGImageSourceRef __nonnull isrc, size_t index);

三、CGImageDestination詳解

CGImageSource是圖片文件數(shù)據(jù)的抽象對(duì)象,而CGImageDestination的作用則是將抽象的圖片數(shù)據(jù)寫入指定的目標(biāo)中。將圖片寫成文件示例如下:

//創(chuàng)建存儲(chǔ)路徑
NSArray *paths=NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask,YES);
NSString *newPath = [paths.firstObject stringByAppendingPathComponent:[NSString stringWithFormat:@"image.png"]];
CFURLRef URL =  CFURLCreateWithFileSystemPath (
                                   kCFAllocatorDefault,
                                   (CFStringRef)newPath,
                                   kCFURLPOSIXPathStyle, 
                                   false);
//創(chuàng)建CGImageDestination對(duì)象
CGImageDestinationRef myImageDest = CGImageDestinationCreateWithURL(URL,CFSTR("public.png"), 1, NULL);
UIImage * image = [UIImage imageNamed:@"timg.jpeg"];
//寫入圖片
CGImageDestinationAddImage(myImageDest, image.CGImage, NULL);
CGImageDestinationFinalize(myImageDest);
CFRelease(myImageDest);

同樣,除了可以直接將圖片數(shù)據(jù)寫入url外,也可以Data數(shù)據(jù)或數(shù)據(jù)消費(fèi)器,方法如下:

//將圖片數(shù)據(jù)寫入數(shù)據(jù)消費(fèi)者
CGImageDestinationRef __nullable CGImageDestinationCreateWithDataConsumer(CGDataConsumerRef __nonnull consumer, CFStringRef __nonnull type, size_t count, CFDictionaryRef __nullable options);
//將圖片數(shù)據(jù)寫入Data
CGImageDestinationRef __nullable CGImageDestinationCreateWithData(CFMutableDataRef __nonnull data, CFStringRef __nonnull type, size_t count, CFDictionaryRef __nullable options);

需要注意,上面方法的type參數(shù)設(shè)置寫入數(shù)據(jù)的文件格式,必須為ImageIO框架所支持的格式,前面有方法可以獲取所有支持的格式,還有一點(diǎn),這3個(gè)寫入方法的中options參數(shù)目前并沒有什么作用,其是留給未來使用的,目前傳入NULL即可。

CGImageDestination類中的其他方法解析如下:

//獲取CGImageDestination的CFTypeID
CFTypeID CGImageDestinationGetTypeID(void);
//獲取CGImageDestination所支持的圖片文件類型
/*
目前支持如下:iOS10.1
 (
    "public.jpeg",
    "public.png",
    "com.compuserve.gif",
    "public.tiff",
    "public.jpeg-2000",
    "com.microsoft.ico",
    "com.microsoft.bmp",
    "com.adobe.photoshop-image",
    "com.adobe.pdf",
    "com.truevision.tga-image",
    "com.ilm.openexr-image",
    "public.pbm",
    "public.pvr",
    "org.khronos.astc",
    "org.khronos.ktx",
    "com.microsoft.dds",
    "com.apple.rjpeg"
)
*/
CFArrayRef __nonnull CGImageDestinationCopyTypeIdentifiers(void);
//設(shè)置圖片文件屬性
/*
可以設(shè)置的鍵值對(duì)意義如下:
const CFStringRef kCGImageDestinationLossyCompressionQuality; //設(shè)置壓縮質(zhì)量 0-1之間的cfnumberref值
const CFStringRef kCGImageDestinationBackgroundColor;  //將圖片數(shù)據(jù)寫為無alpha通道時(shí)的默認(rèn)背景色 cgcolor值
*/
void CGImageDestinationSetProperties(CGImageDestinationRef __nonnull idst, CFDictionaryRef __nullable properties);
//向CGImageDestination中添加一張圖片 其中的option參數(shù)意義和上面一致,設(shè)置此圖片的質(zhì)量與無alpha默認(rèn)背景色
void CGImageDestinationAddImage(CGImageDestinationRef __nonnull idst, CGImageRef __nonnull image, CFDictionaryRef __nullable properties);
//通過CGImageSource對(duì)象來向CGImageDestination中添加圖片
void CGImageDestinationAddImageFromSource(CGImageDestinationRef __nonnull idst, CGImageSourceRef __nonnull isrc, size_t index, CFDictionaryRef __nullable properties);
//進(jìn)行寫入操作 執(zhí)行此方法后 不可以在寫入其他信息
bool CGImageDestinationFinalize(CGImageDestinationRef __nonnull idst);
//添加圖片元信息
void CGImageDestinationAddImageAndMetadata(CGImageDestinationRef __nonnull idst, CGImageRef __nonnull image, CGImageMetadataRef __nullable metadata, CFDictionaryRef __nullable options);
//將CGImageSource信息拷貝進(jìn)CGImageDestination
/*
options參數(shù)可以用來添加元信息
*/
bool CGImageDestinationCopyImageSource(CGImageDestinationRef __nonnull idst, CGImageSourceRef __nonnull isrc, CFDictionaryRef __nullable options, __nullable CFErrorRef * __nullable err);

上面列舉的方法中,CGImageDestinationCopyImageSource()方法中的options參數(shù)可以添加一些圖片的元信息,可以設(shè)置的鍵值對(duì)意義如下:

//設(shè)置元信息 需要設(shè)置為CGImageMetadataRef對(duì)象
const CFStringRef kCGImageDestinationMetadata;
//是否將CGImageSource的元信息信息合并操作 默認(rèn)為kCFBooleanFalse
const CFStringRef kCGImageDestinationMergeMetadata;
//XMP數(shù)據(jù)是否不被寫入 默認(rèn)為kCFBooleanFalse
const CFStringRef kCGImageMetadataShouldExcludeXMP;
//GPS信息是否不被寫入 默認(rèn)為kCFBooleanFalse
const CFStringRef kCGImageMetadataShouldExcludeGPS;
//更新元數(shù)據(jù)的時(shí)間值 需要設(shè)置為CFStringRef或者CFDateRef
const CFStringRef kCGImageDestinationDateTime;
//更新元數(shù)據(jù)的方向值 需要設(shè)置為NSNumber1-8
const CFStringRef kCGImageDestinationOrientation;

四、關(guān)于CGImageMetadata

前面我們很多次提到元數(shù)據(jù),CGImageMetadata類就是元數(shù)據(jù)的抽象,其中封裝了一些方法供開發(fā)者讀取或?qū)懭朐獢?shù)據(jù)信息。奇怪的是Apple的官方文檔與API文檔中并沒有CGImageMetadata的介紹與解釋,博客中本部分的內(nèi)容,多出自我的理解,有疏漏和不對(duì)的地方,清楚的朋友可以指點(diǎn)與建議。

前邊介紹,CGImageSource中有獲取圖片元數(shù)據(jù)的方法,CGImageDestination中也有寫入圖片元數(shù)據(jù)的方法,元數(shù)據(jù)中抽象出的CGImageMetadataTag是對(duì)具體數(shù)據(jù)內(nèi)容的封裝。CGImageMetadata解析如下:
//獲取CGImageMetadata類的CFTypeID
CFTypeID CGImageMetadataGetTypeID(void);
//創(chuàng)建一個(gè)空的可變的CGImageMetadata對(duì)象
CGMutableImageMetadataRef __nonnull CGImageMetadataCreateMutable(void);
//拷貝一個(gè)可變的CGImageMetadata對(duì)象
CGMutableImageMetadataRef __nullable CGImageMetadataCreateMutableCopy(CGImageMetadataRef __nonnull metadata);
//獲取CGImageMetadataTag類的CFTypeID
CFTypeID CGImageMetadataTagGetTypeID(void);
//創(chuàng)建一個(gè)CGImageMetadataTag對(duì)象
/*
這個(gè)方法比較復(fù)雜
xmlns參數(shù)設(shè)置命名空間
prefix參數(shù)設(shè)置命名空間的縮寫或前綴
name參數(shù)設(shè)置CGImageMetadataTag的名稱
type參數(shù)設(shè)置CGImageMetadataTag對(duì)應(yīng)值的類型
value參數(shù)設(shè)置CGImageMetadataTag的對(duì)應(yīng)值
*/
CGImageMetadataTagRef __nullable CGImageMetadataTagCreate (CFStringRef __nonnull xmlns, CFStringRef __nullable prefix, CFStringRef __nonnull name, CGImageMetadataType type, CFTypeRef __nonnull value);

上面創(chuàng)建CGImageMetadataTag的方法中,xmlns設(shè)置命名空間,必須使用一個(gè)預(yù)定義的命名空間或者自定義的命名空間,對(duì)于自定義的命名空間,必須遵守Adobe的XMP規(guī)范。一些共用的命名空間定義如下:

//Exif命名空間
const CFStringRef  kCGImageMetadataNamespaceExif;
//ExifAux命名空間
const CFStringRef  kCGImageMetadataNamespaceExifAux;
//ExifEX命名空間
const CFStringRef  kCGImageMetadataNamespaceExifEX;
//DublineCore命名空間
const CFStringRef  kCGImageMetadataNamespaceDublinCore;
//IPTCCore命名空間
const CFStringRef  kCGImageMetadataNamespaceIPTCCore;
//Photoshop命名空間
const CFStringRef  kCGImageMetadataNamespacePhotoshop;
//TIFF命名空間
const CFStringRef  kCGImageMetadataNamespaceTIFF;
//XMPBasic命名空間
const CFStringRef  kCGImageMetadataNamespaceXMPBasic;
//XMPRights命名空間
const CFStringRef  kCGImageMetadataNamespaceXMPRights;

上面創(chuàng)建CGImageMetadataTag的方法中prefix設(shè)置命名空間縮寫或前綴,同樣一些公用的前綴定義如下:

//Exif命名空間前綴
const CFStringRef  kCGImageMetadataPrefixExif;
//ExifAux命名空間前綴
const CFStringRef  kCGImageMetadataPrefixExifAux;
//ExifEX命名空間前綴
const CFStringRef  kCGImageMetadataPrefixExifEX;
//DublinCore命名空間前綴
const CFStringRef  kCGImageMetadataPrefixDublinCore;
//IPCCore命名空間前綴
const CFStringRef  kCGImageMetadataPrefixIPTCCore;
//Photoshop命名空間前綴
const CFStringRef  kCGImageMetadataPrefixPhotoshop;
//TIFF命名空間前綴
const CFStringRef  kCGImageMetadataPrefixTIFF;
//XMPBasic命名空間前綴
const CFStringRef  kCGImageMetadataPrefixXMPBasic;
//XMPRights命名空間前綴
const CFStringRef  kCGImageMetadataPrefixXMPRights;

上面創(chuàng)建CGImageMetadataTag的方法中type設(shè)置對(duì)應(yīng)值的類型,其是一個(gè)CGImageMetadataType類型的枚舉,意義如下:

typedef CF_ENUM(int32_t, CGImageMetadataType) {
    //無效的數(shù)據(jù)類型
    kCGImageMetadataTypeInvalid = -1,
    //基本的CFType類型
    kCGImageMetadataTypeDefault = 0,
    //字符串類型
    kCGImageMetadataTypeString = 1,
    //無需集合類型
    kCGImageMetadataTypeArrayUnordered = 2,
    //有序集合類型
    kCGImageMetadataTypeArrayOrdered = 3,
    //有序陣列
    kCGImageMetadataTypeAlternateArray = 4,
    //特殊的數(shù)組 其中元素進(jìn)行不同的本地化
    kCGImageMetadataTypeAlternateText = 5,
    //結(jié)構(gòu)類型 如字典
    kCGImageMetadataTypeStructure = 6
};

獲取到CGImageMetadataTag后,可以通過如下方法來獲取其中封裝的信息:

//獲取標(biāo)簽的命名空間
CFStringRef __nullable CGImageMetadataTagCopyNamespace(CGImageMetadataTagRef __nonnull tag);
//獲取標(biāo)簽的命名空間前綴
CFStringRef __nullable CGImageMetadataTagCopyPrefix(CGImageMetadataTagRef __nonnull tag);
//獲取標(biāo)簽名稱
CFStringRef __nullable CGImageMetadataTagCopyName(CGImageMetadataTagRef __nonnull tag);
//獲取標(biāo)簽的值
CFTypeRef __nullable CGImageMetadataTagCopyValue(CGImageMetadataTagRef __nonnull tag);
//獲取標(biāo)簽值的類型
CGImageMetadataType CGImageMetadataTagGetType(CGImageMetadataTagRef __nonnull tag);
//獲取標(biāo)簽的Qualifier數(shù)組
CFArrayRef __nullable CGImageMetadataTagCopyQualifiers(CGImageMetadataTagRef __nonnull tag);

下面這些方法用于向CGImageMetadata中添加標(biāo)簽或者獲取標(biāo)簽:

//獲取CGImageMetadata中的所有標(biāo)簽
CFArrayRef __nullable CGImageMetadataCopyTags(CGImageMetadataRef __nonnull metadata);
//通過路徑查找特殊的標(biāo)簽
CGImageMetadataTagRef __nullable CGImageMetadataCopyTagWithPath(CGImageMetadataRef __nonnull metadata, CGImageMetadataTagRef __nullable parent, CFStringRef __nonnull path);
//通過路徑查找特殊標(biāo)簽的值
 CFStringRef __nullable CGImageMetadataCopyStringValueWithPath(CGImageMetadataRef __nonnull metadata, CGImageMetadataTagRef __nullable parent, CFStringRef __nonnull path);
//為一個(gè)前綴注冊(cè)一個(gè)命名空間
bool CGImageMetadataRegisterNamespaceForPrefix(CGMutableImageMetadataRef __nonnull metadata, CFStringRef __nonnull xmlns, CFStringRef __nonnull prefix, __nullable CFErrorRef * __nullable err);
//通過路徑為CGImageMetadata設(shè)置標(biāo)簽
bool CGImageMetadataSetTagWithPath(CGMutableImageMetadataRef __nonnull metadata, CGImageMetadataTagRef __nullable parent, CFStringRef __nonnull path, CGImageMetadataTagRef __nonnull tag);
//通過路徑為CGImageMetadata設(shè)置標(biāo)簽的值
bool CGImageMetadataSetValueWithPath(CGMutableImageMetadataRef __nonnull metadata, CGImageMetadataTagRef __nullable parent, CFStringRef __nonnull path, CFTypeRef __nonnull value);
//通過路徑移除一個(gè)標(biāo)簽
bool CGImageMetadataRemoveTagWithPath(CGMutableImageMetadataRef __nonnull metadata,  CGImageMetadataTagRef __nullable parent, CFStringRef __nonnull path);
//對(duì)標(biāo)簽進(jìn)行枚舉
void CGImageMetadataEnumerateTagsUsingBlock(CGImageMetadataRef __nonnull metadata, CFStringRef __nullable rootPath, CFDictionaryRef __nullable options, CGImageMetadataTagBlock __nonnull block);

五、CGImageProperties中定義的字典意義

前面提到的CGImageSourceCopyProperties方法與CGImageSourceCopyPropertiesAtIndex方法都會(huì)返回一個(gè)字典,字典中可能包含如下有意義的鍵:

//TIFF信息字典
const CFStringRef kCGImagePropertyTIFFDictionary;
/GIF信息字典
const CFStringRef kCGImagePropertyGIFDictionary;
//JFIF信息字典
const CFStringRef kCGImagePropertyJFIFDictionary;
//EXif信息字典
const CFStringRef kCGImagePropertyExifDictionary;
//PNG信息字典
const CFStringRef kCGImagePropertyPNGDictionary;
//IPTC信息字典
const CFStringRef kCGImagePropertyIPTCDictionary;
//GPS信息字典
const CFStringRef kCGImagePropertyGPSDictionary;
//原始信息字典
const CFStringRef kCGImagePropertyRawDictionary;
//CIFF信息字典
const CFStringRef kCGImagePropertyCIFFDictionary;
//佳能相機(jī)信息字典
const CFStringRef kCGImagePropertyMakerCanonDictionary;
//尼康相機(jī)信息字典
const CFStringRef kCGImagePropertyMakerNikonDictionary;
//柯尼卡相機(jī)信息字典
const CFStringRef kCGImagePropertyMakerMinoltaDictionary;
//富士相機(jī)信息字典
const CFStringRef kCGImagePropertyMakerFujiDictionary;
//奧林巴斯相機(jī)信息字典
const CFStringRef kCGImagePropertyMakerOlympusDictionary;
//賓得相機(jī)信息字典
const CFStringRef kCGImagePropertyMakerPentaxDictionary;
//對(duì)應(yīng)Photoshop相片的信息字典
const CFStringRef kCGImageProperty8BIMDictionary;
//NDG信息字典
const CFStringRef kCGImagePropertyDNGDictionary ;
//ExifAux信息字典
const CFStringRef kCGImagePropertyExifAuxDictionary;
//OpenEXR信息字典
const CFStringRef kCGImagePropertyOpenEXRDictionary;
//Apple相機(jī)信息字典
const CFStringRef kCGImagePropertyMakerAppleDictionary ;

CGImageSourceCopyProperties方法返回的字典中還可能會(huì)有如下一個(gè)特殊的鍵:

//對(duì)應(yīng)文件大小
const CFStringRef kCGImagePropertyFileSize;

CGImageSourceCopyPropertiesAtIndex方法中可能包含的特殊鍵:

//像素高度
const CFStringRef kCGImagePropertyPixelHeight;
//像素寬度
const CFStringRef kCGImagePropertyPixelWidth;
//DPI高度
const CFStringRef kCGImagePropertyDPIHeight;
//DPI寬度
const CFStringRef kCGImagePropertyDPIWidth;
//顏色位數(shù)
const CFStringRef kCGImagePropertyDepth;
//圖片的顯示方向
/*
對(duì)應(yīng)Number值
 *   1  =  左上到右下.  
 *   2  =  右上到左下.  
 *   3  =  右下到左上.
 *   4  =  左下到右上.  
 *   5  =  行列置換 左上到右下.  
 *   6  =  行列置換 右上到左下.  
 *   7  =  行列置換 右下到左上.  
 *   8  =  行列置換 左下到右上.
*/
const CFStringRef kCGImagePropertyOrientation;
//顏色是否支持浮點(diǎn)數(shù)
const CFStringRef kCGImagePropertyIsFloat;
//圖像是否包含像素樣本
const CFStringRef kCGImagePropertyIsIndexed;
//圖像是否包含alpha通道
const CFStringRef kCGImagePropertyHasAlpha;
//圖像的顏色模式
const CFStringRef kCGImagePropertyColorModel;
//嵌入圖片的ICC配置文件名稱
const CFStringRef kCGImagePropertyProfileName;

kCGImagePropertyColorModel鍵可返回的值有如下幾種定義:

//RBG模式
const CFStringRef kCGImagePropertyColorModelRGB;
//Gray模式
const CFStringRef kCGImagePropertyColorModelGray;
//CMYK模式
const CFStringRef kCGImagePropertyColorModelCMYK;
//Lab模式
const CFStringRef kCGImagePropertyColorModelLab;

kCGImagePropertyTIFFDictionary鍵可返回的值定義如下:

//圖片數(shù)據(jù)壓縮方案
const CFStringRef kCGImagePropertyTIFFCompression;
//圖片數(shù)據(jù)的色彩空間
const CFStringRef kCGImagePropertyTIFFPhotometricInterpretation;
//文檔名稱
const CFStringRef kCGImagePropertyTIFFDocumentName;
//圖片描述
const CFStringRef kCGImagePropertyTIFFImageDescription;
//相機(jī)設(shè)備名
const CFStringRef kCGImagePropertyTIFFMake;
//相機(jī)設(shè)備模式
const CFStringRef kCGImagePropertyTIFFModel;
//圖片方向
const CFStringRef kCGImagePropertyTIFFOrientation;
//橫向每個(gè)分辨位的像素?cái)?shù)
const CFStringRef kCGImagePropertyTIFFXResolution;
//縱向每個(gè)分辨位的像素?cái)?shù)
const CFStringRef kCGImagePropertyTIFFYResolution;
//分辨率單位
const CFStringRef kCGImagePropertyTIFFResolutionUnit;
//創(chuàng)建圖像的軟件名稱和版本
const CFStringRef kCGImagePropertyTIFFSoftware;
//transform函數(shù)
const CFStringRef kCGImagePropertyTIFFTransferFunction;
//日期時(shí)間
const CFStringRef kCGImagePropertyTIFFDateTime;
//作者
const CFStringRef kCGImagePropertyTIFFArtist;
//創(chuàng)建圖片的電腦系統(tǒng)
const CFStringRef kCGImagePropertyTIFFHostComputer;
//公司信息
const CFStringRef kCGImagePropertyTIFFCopyright;
//圖片的白點(diǎn)
const CFStringRef kCGImagePropertyTIFFWhitePoint;
//圖像的原色色度
const CFStringRef kCGImagePropertyTIFFPrimaryChromaticities;
//圖片的瓦片寬度
const CFStringRef kCGImagePropertyTIFFTileWidth;
//圖片的瓦片高度
const CFStringRef kCGImagePropertyTIFFTileLength;

kCGImagePropertyJFIFDictionary對(duì)應(yīng)的字典中可能包含如下意義的鍵:

//JFIF版本
const CFStringRef kCGImagePropertyJFIFVersion;
//橫向像素密度
const CFStringRef kCGImagePropertyJFIFXDensity;
//縱向像素密度
const CFStringRef kCGImagePropertyJFIFYDensity;
//像素密度單元
const CFStringRef kCGImagePropertyJFIFDensityUnit;
//是否是高質(zhì)量圖像版本
const CFStringRef kCGImagePropertyJFIFIsProgressive;

kCGImagePropertyExifDictionary對(duì)應(yīng)的字典中可能包含如下意義的鍵 :

//曝光時(shí)間
const CFStringRef kCGImagePropertyExifExposureTime;
//ExifNumber
const CFStringRef kCGImagePropertyExifFNumber;
//曝光程序
const CFStringRef kCGImagePropertyExifExposureProgram;
//每個(gè)通道的光譜靈敏度
const CFStringRef kCGImagePropertyExifSpectralSensitivity;
//ISO速度等級(jí)
const CFStringRef kCGImagePropertyExifISOSpeedRatings;
//ExifOECF
const CFStringRef kCGImagePropertyExifOECF;
//靈敏類型
const CFStringRef kCGImagePropertyExifSensitivityType;
//輸出靈敏標(biāo)準(zhǔn)
const CFStringRef kCGImagePropertyExifStandardOutputSensitivity;
//推薦曝光指數(shù)
const CFStringRef kCGImagePropertyExifRecommendedExposureIndex;
//ISO速率
const CFStringRef kCGImagePropertyExifISOSpeed;
const CFStringRef kCGImagePropertyExifISOSpeedLatitudeyyy;
const CFStringRef kCGImagePropertyExifISOSpeedLatitudezzz;
//Exif版本
const CFStringRef kCGImagePropertyExifVersion;
//原始日期時(shí)間
const CFStringRef kCGImagePropertyExifDateTimeOriginal;
//數(shù)字化日期時(shí)間
const CFStringRef kCGImagePropertyExifDateTimeDigitized;
//壓縮配置
const CFStringRef kCGImagePropertyExifComponentsConfiguration;
//壓縮模式像素位
const CFStringRef kCGImagePropertyExifCompressedBitsPerPixel;
//快門速度值
const CFStringRef kCGImagePropertyExifShutterSpeedValue;
//孔徑值
const CFStringRef kCGImagePropertyExifApertureValue;
//亮度值
const CFStringRef kCGImagePropertyExifBrightnessValue;
//曝光偏差值
const CFStringRef kCGImagePropertyExifExposureBiasValue;
//最大光圈值
const CFStringRef kCGImagePropertyExifMaxApertureValue;
//距離
const CFStringRef kCGImagePropertyExifSubjectDistance;
//測(cè)光模式
const CFStringRef kCGImagePropertyExifMeteringMode;
//光源
const CFStringRef kCGImagePropertyExifLightSource;
//拍攝時(shí)的閃光狀態(tài)
const CFStringRef kCGImagePropertyExifFlash;
//焦距
const CFStringRef kCGImagePropertyExifFocalLength;
//主體區(qū)域
const CFStringRef kCGImagePropertyExifSubjectArea;
//相機(jī)制造商指定的信息
const CFStringRef kCGImagePropertyExifMakerNote;
//用戶信息
const CFStringRef kCGImagePropertyExifUserComment;
//日期和時(shí)間標(biāo)記的秒分?jǐn)?shù)
const CFStringRef kCGImagePropertyExifSubsecTime;
//原始時(shí)間
const CFStringRef kCGImagePropertyExifSubsecTimeOriginal;
//數(shù)字時(shí)間
const CFStringRef kCGImagePropertyExifSubsecTimeDigitized;
//FlashPix版本信息
const CFStringRef kCGImagePropertyExifFlashPixVersion;
//色彩空間
const CFStringRef kCGImagePropertyExifColorSpace;
//X方向像素
const CFStringRef kCGImagePropertyExifPixelXDimension;
//Y方向像素
const CFStringRef kCGImagePropertyExifPixelYDimension;
//與圖像相關(guān)的聲音文件
const CFStringRef kCGImagePropertyExifRelatedSoundFile;
//FlashEnergy
const CFStringRef kCGImagePropertyExifFlashEnergy;
//FrequencyResponse
const CFStringRef kCGImagePropertyExifSpatialFrequencyResponse;
//像素?cái)?shù)目
const CFStringRef kCGImagePropertyExifFocalPlaneXResolution;
const CFStringRef kCGImagePropertyExifFocalPlaneYResolution;
const CFStringRef kCGImagePropertyExifFocalPlaneResolutionUnit;
//圖像主體的位置
const CFStringRef kCGImagePropertyExifSubjectLocation;
//選擇的曝光指數(shù)
const CFStringRef kCGImagePropertyExifExposureIndex;
//傳感器類型
const CFStringRef kCGImagePropertyExifSensingMethod;
//圖像文件源
const CFStringRef kCGImagePropertyExifFileSource;
//場景類型
const CFStringRef kCGImagePropertyExifSceneType;
//CFA模塊
const CFStringRef kCGImagePropertyExifCFAPattern;
//對(duì)圖像數(shù)據(jù)進(jìn)行特殊渲染
const CFStringRef kCGImagePropertyExifCustomRendered;
//曝光模式設(shè)置
const CFStringRef kCGImagePropertyExifExposureMode;
//白平衡模式
const CFStringRef kCGImagePropertyExifWhiteBalance;
//數(shù)字變焦比
const CFStringRef kCGImagePropertyExifDigitalZoomRatio;
//35毫米膠片的等效焦距
const CFStringRef kCGImagePropertyExifFocalLenIn35mmFilm;
//場景捕捉類型(標(biāo)準(zhǔn),景觀,肖像,夜晚)
const CFStringRef kCGImagePropertyExifSceneCaptureType;
//圖像增益
const CFStringRef kCGImagePropertyExifGainControl;
//圖像對(duì)比度
const CFStringRef kCGImagePropertyExifContrast;
//圖像飽和度
const CFStringRef kCGImagePropertyExifSaturation;
//圖像銳度
const CFStringRef kCGImagePropertyExifSharpness;
//拍攝條件
const CFStringRef kCGImagePropertyExifDeviceSettingDescription;
//主體距離
const CFStringRef kCGImagePropertyExifSubjectDistRange;
//圖像的唯一標(biāo)識(shí)
const CFStringRef kCGImagePropertyExifImageUniqueID;
//相機(jī)所有者
const CFStringRef kCGImagePropertyExifCameraOwnerName;
//相機(jī)序列號(hào)
const CFStringRef kCGImagePropertyExifBodySerialNumber;
//透鏡規(guī)格信息
const CFStringRef kCGImagePropertyExifLensSpecification;
//透鏡制造商名稱
const CFStringRef kCGImagePropertyExifLensMake;
//透鏡模式
const CFStringRef kCGImagePropertyExifLensModel;
//透鏡序列號(hào)
const CFStringRef kCGImagePropertyExifLensSerialNumber;
//伽馬設(shè)置
const CFStringRef kCGImagePropertyExifGamma;

kCGImagePropertyExifAuxDictionary對(duì)應(yīng)的字典中可能包含的鍵定義如下:

//鏡頭信息
const CFStringRef kCGImagePropertyExifAuxLensInfo;
//鏡頭模式
const CFStringRef kCGImagePropertyExifAuxLensModel;
//序列號(hào)
const CFStringRef kCGImagePropertyExifAuxSerialNumber;
//鏡頭ID
const CFStringRef kCGImagePropertyExifAuxLensID;
//鏡頭序列號(hào)
const CFStringRef kCGImagePropertyExifAuxLensSerialNumber;
//圖片編號(hào)
const CFStringRef kCGImagePropertyExifAuxImageNumber;
//閃光補(bǔ)償
const CFStringRef kCGImagePropertyExifAuxFlashCompensation;
//所有者名稱
const CFStringRef kCGImagePropertyExifAuxOwnerName;
//固件信息
const CFStringRef kCGImagePropertyExifAuxFirmware;

kCGImagePropertyGIFDictionary對(duì)應(yīng)的字典中可能包含的鍵定義如下:

//動(dòng)畫循環(huán)次數(shù)
const CFStringRef kCGImagePropertyGIFLoopCount;
//兩幀之間的延時(shí)
const CFStringRef kCGImagePropertyGIFDelayTime;
//顏色Map
const CFStringRef kCGImagePropertyGIFImageColorMap;
const CFStringRef kCGImagePropertyGIFHasGlobalColorMap;
//兩幀之間的延時(shí)
const CFStringRef kCGImagePropertyGIFUnclampedDelayTime;

kCGImagePropertyPNGDictionary對(duì)應(yīng)的字典中可能包含的鍵定義如下:

//PNG伽馬值
const CFStringRef kCGImagePropertyPNGGamma;
//混合類型
const CFStringRef kCGImagePropertyPNGInterlaceType;
//X方向像素?cái)?shù)
const CFStringRef kCGImagePropertyPNGXPixelsPerMeter;
//Y方向像素?cái)?shù)
const CFStringRef kCGImagePropertyPNGYPixelsPerMeter;
//RGB意圖
const CFStringRef kCGImagePropertyPNGsRGBIntent;
//色度
const CFStringRef kCGImagePropertyPNGChromaticities;
//作者
const CFStringRef kCGImagePropertyPNGAuthor;
//公司
const CFStringRef kCGImagePropertyPNGCopyright;
//創(chuàng)建時(shí)間
const CFStringRef kCGImagePropertyPNGCreationTime;
//描述
const CFStringRef kCGImagePropertyPNGDescription;
//最后修改日期時(shí)間
const CFStringRef kCGImagePropertyPNGModificationTime;
//軟件
const CFStringRef kCGImagePropertyPNGSoftware;
//標(biāo)題
const CFStringRef kCGImagePropertyPNGTitle;
//動(dòng)畫循環(huán)次數(shù)
const CFStringRef kCGImagePropertyAPNGLoopCount;
//兩幀之間的延時(shí)
const CFStringRef kCGImagePropertyAPNGDelayTime;
const CFStringRef kCGImagePropertyAPNGUnclampedDelayTime;

kCGImagePropertyGPSDictionary對(duì)應(yīng)的字典中可能包含的鍵定義如下:

//GPS版本
const CFStringRef kCGImagePropertyGPSVersion;
//緯度是南緯或北緯
const CFStringRef kCGImagePropertyGPSLatitudeRef;
//緯度
const CFStringRef kCGImagePropertyGPSLatitude;
//經(jīng)度是東經(jīng)或西經(jīng)
const CFStringRef kCGImagePropertyGPSLongitudeRef;
//經(jīng)度
const CFStringRef kCGImagePropertyGPSLongitude;
//海拔標(biāo)準(zhǔn)
const CFStringRef kCGImagePropertyGPSAltitudeRef;
//海拔高度
const CFStringRef kCGImagePropertyGPSAltitude;
//時(shí)間戳
const CFStringRef kCGImagePropertyGPSTimeStamp;
//測(cè)量GPS的衛(wèi)星
const CFStringRef kCGImagePropertyGPSSatellites;
//GPS狀態(tài)
const CFStringRef kCGImagePropertyGPSStatus;
//測(cè)量模式
const CFStringRef kCGImagePropertyGPSMeasureMode;
//精度數(shù)據(jù)
const CFStringRef kCGImagePropertyGPSDOP;
//速度標(biāo)準(zhǔn)
const CFStringRef kCGImagePropertyGPSSpeedRef;
//速度
const CFStringRef kCGImagePropertyGPSSpeed;
//運(yùn)動(dòng)方向參考
const CFStringRef kCGImagePropertyGPSTrackRef;
//運(yùn)動(dòng)方向
const CFStringRef kCGImagePropertyGPSTrack;
//位置方向參考
const CFStringRef kCGImagePropertyGPSImgDirectionRef;
//位置方向
const CFStringRef kCGImagePropertyGPSImgDirection;
//地圖測(cè)量數(shù)據(jù)
const CFStringRef kCGImagePropertyGPSMapDatum;
//地理緯度南緯或北緯
const CFStringRef kCGImagePropertyGPSDestLatitudeRef;
//地理緯度
const CFStringRef kCGImagePropertyGPSDestLatitude;
//地理經(jīng)度 東經(jīng)或西經(jīng)
const CFStringRef kCGImagePropertyGPSDestLongitudeRef;
//地理經(jīng)度
const CFStringRef kCGImagePropertyGPSDestLongitude;
//方位參照
const CFStringRef kCGImagePropertyGPSDestBearingRef;
//地理方位
const CFStringRef kCGImagePropertyGPSDestBearing;
//距離參照
const CFStringRef kCGImagePropertyGPSDestDistanceRef;
//距離
const CFStringRef kCGImagePropertyGPSDestDistance;
//查找地理位置的方法
const CFStringRef kCGImagePropertyGPSProcessingMethod;
//GPS地區(qū)名
const CFStringRef kCGImagePropertyGPSAreaInformation;
//日期時(shí)間
const CFStringRef kCGImagePropertyGPSDateStamp;
//校正信息
const CFStringRef kCGImagePropertyGPSDifferental;
//錯(cuò)誤信息
const CFStringRef kCGImagePropertyGPSHPositioningError;

kCGImagePropertyIPTCDictionary對(duì)應(yīng)的字典中可能包含的鍵定義如下:

//對(duì)象類型
const CFStringRef kCGImagePropertyIPTCObjectTypeReference;
//對(duì)象屬性
const CFStringRef kCGImagePropertyIPTCObjectAttributeReference;
//對(duì)象名稱
const CFStringRef kCGImagePropertyIPTCObjectName;
//編輯狀態(tài)
const CFStringRef kCGImagePropertyIPTCEditStatus;
//更新狀態(tài)
const CFStringRef kCGImagePropertyIPTCEditorialUpdate;
//緊急等級(jí)
const CFStringRef kCGImagePropertyIPTCUrgency;
//主體
const CFStringRef kCGImagePropertyIPTCSubjectReference;
//類別
const CFStringRef kCGImagePropertyIPTCCategory;
//補(bǔ)充類別
const CFStringRef kCGImagePropertyIPTCSupplementalCategory;
//Fixture標(biāo)識(shí)
const CFStringRef kCGImagePropertyIPTCFixtureIdentifier;
//關(guān)鍵字
const CFStringRef kCGImagePropertyIPTCKeywords;
//內(nèi)容定位碼
const CFStringRef kCGImagePropertyIPTCContentLocationCode;
//內(nèi)容位置名稱
const CFStringRef kCGImagePropertyIPTCContentLocationName;
//圖像使用的最早日期
const CFStringRef kCGImagePropertyIPTCReleaseDate;
//圖像使用的最早時(shí)間
const CFStringRef kCGImagePropertyIPTCReleaseTime;
//最后一次使用日期
const CFStringRef kCGImagePropertyIPTCExpirationDate;
//最后一次使用時(shí)間
const CFStringRef kCGImagePropertyIPTCExpirationTime;
//圖像使用的特別說明
const CFStringRef kCGImagePropertyIPTCSpecialInstructions;
//建議行為
const CFStringRef kCGImagePropertyIPTCActionAdvised;
//服務(wù)參考
const CFStringRef kCGImagePropertyIPTCReferenceService;
//日期參考
const CFStringRef kCGImagePropertyIPTCReferenceDate;
//參考碼
const CFStringRef kCGImagePropertyIPTCReferenceNumber;
//創(chuàng)建日期
const CFStringRef kCGImagePropertyIPTCDateCreated;
//創(chuàng)建時(shí)間
const CFStringRef kCGImagePropertyIPTCTimeCreated;
//數(shù)字創(chuàng)建日期
const CFStringRef kCGImagePropertyIPTCDigitalCreationDate;
//數(shù)字創(chuàng)建時(shí)間
const CFStringRef kCGImagePropertyIPTCDigitalCreationTime;
//原始程序
const CFStringRef kCGImagePropertyIPTCOriginatingProgram;
//程序版本
const CFStringRef kCGImagePropertyIPTCProgramVersion;
圖像的編輯周期(早晨,晚上或兩者)。
const CFStringRef kCGImagePropertyIPTCObjectCycle;
//不想創(chuàng)建者名稱
const CFStringRef kCGImagePropertyIPTCByline;
//圖像創(chuàng)建標(biāo)題
const CFStringRef kCGImagePropertyIPTCBylineTitle;
//城市信息
const CFStringRef kCGImagePropertyIPTCCity;
//城市內(nèi)位置
const CFStringRef kCGImagePropertyIPTCSubLocation;
//省份
const CFStringRef kCGImagePropertyIPTCProvinceState;
//國家編碼
const CFStringRef kCGImagePropertyIPTCCountryPrimaryLocationCode;
//國家名稱
const CFStringRef kCGImagePropertyIPTCCountryPrimaryLocationName;
//OriginalTransmission參考
const CFStringRef kCGImagePropertyIPTCOriginalTransmissionReference;
//圖像內(nèi)容摘要
const CFStringRef kCGImagePropertyIPTCHeadline;
//提供圖像服務(wù)的名稱
const CFStringRef kCGImagePropertyIPTCCredit;
//圖像源
const CFStringRef kCGImagePropertyIPTCSource;
//公司提示
const CFStringRef kCGImagePropertyIPTCCopyrightNotice;
//聯(lián)系人
const CFStringRef kCGImagePropertyIPTCContact;
//描述
const CFStringRef kCGImagePropertyIPTCCaptionAbstract;
//圖像編輯者
const CFStringRef kCGImagePropertyIPTCWriterEditor;
//圖像類型
const CFStringRef kCGImagePropertyIPTCImageType;
//方向信息
const CFStringRef kCGImagePropertyIPTCImageOrientation;
//語言信息
const CFStringRef kCGImagePropertyIPTCLanguageIdentifier;
//星級(jí)
const CFStringRef kCGImagePropertyIPTCStarRating;
//聯(lián)系人詳細(xì)信息
const CFStringRef kCGImagePropertyIPTCCreatorContactInfo;
//圖像使用權(quán)限
const CFStringRef kCGImagePropertyIPTCRightsUsageTerms;
//場景代碼
const CFStringRef kCGImagePropertyIPTCScene;

上面的kCGImagePropertyIPTCCreatorContactInfo對(duì)應(yīng)的字典中鍵的定義如下:

//聯(lián)系人城市
const CFStringRef kCGImagePropertyIPTCContactInfoCity;
//聯(lián)系人國家
const CFStringRef kCGImagePropertyIPTCContactInfoCountry;
//聯(lián)系人地址
const CFStringRef kCGImagePropertyIPTCContactInfoAddress;
//郵編
const CFStringRef kCGImagePropertyIPTCContactInfoPostalCode;
//省份
const CFStringRef kCGImagePropertyIPTCContactInfoStateProvince;
//電子郵件
const CFStringRef kCGImagePropertyIPTCContactInfoEmails;
//電話
const CFStringRef kCGImagePropertyIPTCContactInfoPhones;
//網(wǎng)址
const CFStringRef kCGImagePropertyIPTCContactInfoWebURLs;

kCGImageProperty8BIMDictionary對(duì)應(yīng)的字典中可能包含的鍵定義如下:

//Photoshop文件的圖層名
const CFStringRef  kCGImageProperty8BIMLayerNames;
//版本
const CFStringRef  kCGImageProperty8BIMVersion;

kCGImagePropertyDNGDictionary對(duì)應(yīng)的字典中可能包含的鍵定義如下:

//DNG版本
const CFStringRef  kCGImagePropertyDNGVersion;
//兼容的最老版本
const CFStringRef  kCGImagePropertyDNGBackwardVersion;
//攝像機(jī)模型
const CFStringRef  kCGImagePropertyDNGUniqueCameraModel;
const CFStringRef  kCGImagePropertyDNGLocalizedCameraModel;
//相機(jī)序列碼
const CFStringRef  kCGImagePropertyDNGCameraSerialNumber;
//鏡頭信息
const CFStringRef  kCGImagePropertyDNGLensInfo;
//黑度等級(jí)
const CFStringRef  kCGImagePropertyDNGBlackLevel;
//白度等級(jí)
const CFStringRef  kCGImagePropertyDNGWhiteLevel;

const CFStringRef  kCGImagePropertyDNGCalibrationIlluminant1;
const CFStringRef  kCGImagePropertyDNGCalibrationIlluminant2;
const CFStringRef  kCGImagePropertyDNGColorMatrix1;
const CFStringRef  kCGImagePropertyDNGColorMatrix2;
const CFStringRef  kCGImagePropertyDNGCameraCalibration1;
const CFStringRef  kCGImagePropertyDNGCameraCalibration2;
const CFStringRef  kCGImagePropertyDNGAsShotNeutral;
const CFStringRef  kCGImagePropertyDNGAsShotWhiteXY;
const CFStringRef  kCGImagePropertyDNGBaselineExposure;
const CFStringRef  kCGImagePropertyDNGBaselineNoise;
const CFStringRef  kCGImagePropertyDNGBaselineSharpness;
const CFStringRef  kCGImagePropertyDNGPrivateData;
const CFStringRef  kCGImagePropertyDNGCameraCalibrationSignature;
const CFStringRef  kCGImagePropertyDNGProfileCalibrationSignature;
const CFStringRef  kCGImagePropertyDNGNoiseProfile;
const CFStringRef  kCGImagePropertyDNGWarpRectilinear;
const CFStringRef  kCGImagePropertyDNGWarpFisheye;
const CFStringRef  kCGImagePropertyDNGFixVignetteRadial;

kCGImagePropertyCIFFDictionary對(duì)應(yīng)的字典中可能包含的鍵定義如下:

//相機(jī)信息
const CFStringRef  kCGImagePropertyCIFFDescription;
//固件版本
const CFStringRef  kCGImagePropertyCIFFFirmware;
//所有者名稱
const CFStringRef  kCGImagePropertyCIFFOwnerName;
//圖片名
const CFStringRef  kCGImagePropertyCIFFImageName;
//圖片文件名
const CFStringRef  kCGImagePropertyCIFFImageFileName;
//曝光方式
const CFStringRef  kCGImagePropertyCIFFReleaseMethod;
//曝光時(shí)間
const CFStringRef  kCGImagePropertyCIFFReleaseTiming;
//RecordID
const CFStringRef  kCGImagePropertyCIFFRecordID;
//曝光時(shí)間
const CFStringRef  kCGImagePropertyCIFFSelfTimingTime;
//相機(jī)序列號(hào)
const CFStringRef  kCGImagePropertyCIFFCameraSerialNumber;
//圖片編碼
const CFStringRef  kCGImagePropertyCIFFImageSerialNumber;
//驅(qū)動(dòng)模式
const CFStringRef  kCGImagePropertyCIFFContinuousDrive);
//焦點(diǎn)模式
const CFStringRef  kCGImagePropertyCIFFFocusMode;
//測(cè)量模式
const CFStringRef  kCGImagePropertyCIFFMeteringMode;
//曝光模式
const CFStringRef  kCGImagePropertyCIFFShootingMode;
//透鏡模式
const CFStringRef  kCGImagePropertyCIFFLensModel;
//最長鏡頭長度
const CFStringRef  kCGImagePropertyCIFFLensMaxMM;
//最短鏡頭長度
const CFStringRef  kCGImagePropertyCIFFLensMinMM;
//白平衡等級(jí)
const CFStringRef  kCGImagePropertyCIFFWhiteBalanceIndex;
//曝光補(bǔ)償
const CFStringRef  kCGImagePropertyCIFFFlashExposureComp;
//實(shí)測(cè)曝光值
const CFStringRef  kCGImagePropertyCIFFMeasuredEV);

六、ImageIO框架在實(shí)際開發(fā)中的幾個(gè)應(yīng)用

1.顯示特殊格式的圖片

在平時(shí)開發(fā)中,我們通常使用UIImage來讀取圖片,UIImage支持的圖片包括png與jpg等,但是類似windows系統(tǒng)的ico圖標(biāo),UIImage默認(rèn)是無法顯示的,可以通過ImageIO框架來在iOS系統(tǒng)中使用ico圖標(biāo),示例如下:

NSString * path = [[NSBundle mainBundle]pathForResource:@"image" ofType:@"ico"];
    NSURL * url = [NSURL fileURLWithPath:path];
    CGImageRef myImage = NULL;
    CGImageSourceRef myImageSource;
    CFDictionaryRef myOptions = NULL;
    myImageSource = CGImageSourceCreateWithURL((CFURLRef)url, NULL);
    myImage = CGImageSourceCreateImageAtIndex(myImageSource,
                                              0,
                                              NULL);
    CFRelease(myImageSource);
    UIImageView * image = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 200, 200)];
    image.image = [UIImage imageWithCGImage:myImage];

2.讀取數(shù)碼相機(jī)拍攝圖片的地理位置、時(shí)間等信息

3.對(duì)相冊(cè)中圖片的地理位置,時(shí)間等信息進(jìn)行自定義修改。

4.將自定義格式的圖片數(shù)據(jù)寫入本地文件。

5.展示GIF動(dòng)圖

詳情見博客:https://my.oschina.net/u/2340880/blog/608560。

6.漸進(jìn)渲染大圖

漸進(jìn)渲染技術(shù)在對(duì)加載大圖片時(shí)特別重要,你應(yīng)該使用過地圖軟件,地圖視圖在加載時(shí)是局部進(jìn)行加載,當(dāng)移動(dòng)或者放大時(shí),地圖會(huì)一部分一部分的漸進(jìn)進(jìn)行加載,使用ImageIO框架可以實(shí)現(xiàn)大圖漸進(jìn)渲染的效果,一般在對(duì)大圖片進(jìn)行網(wǎng)絡(luò)請(qǐng)求時(shí),可以獲取一部分?jǐn)?shù)據(jù)就加載一部分?jǐn)?shù)據(jù),為了便于演示,博客中使用定時(shí)器來默認(rèn)網(wǎng)絡(luò)返回?cái)?shù)據(jù),代碼示例如下:

@interface ViewController ()
{
    NSMutableData * _data;
    NSData * _allData;
    NSUInteger length;
    UIImageView * _imageView;
    NSTimer * timer;
    NSInteger le;
}
@end
@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    _data = [[NSMutableData alloc]init];
    NSString * path = [[NSBundle mainBundle]pathForResource:@"Default-Portrait-ns@2x" ofType:@"png"];
    _allData = [NSData dataWithContentsOfFile:path];
    length = _allData.length;
    le = length/10;
    timer = [NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(updateImage) userInfo:nil repeats:YES];
    _imageView = [[UIImageView alloc]initWithFrame:self.view.frame];
    [self.view addSubview:_imageView];
}


-(void)updateImage{
    static int index = 0;
    if (index==10) {
        return;
    }
    NSUInteger l;
    if (index==9) {
        l=length-le*9;
    }else{
        l= le;
    }
    
    Byte by[l];
    [_allData getBytes:by range:NSMakeRange(index*le, l)];
    [_data appendBytes:by length:l];
    CGImageSourceRef myImageSource = CGImageSourceCreateWithData((CFDataRef)_data, NULL);
    CGImageRef myImage = CGImageSourceCreateImageAtIndex(myImageSource,
                                              0,
                                              NULL);
    CFRelease(myImageSource);
    
    _imageView.image = [UIImage imageWithCGImage:myImage];
    //    image.image = [UIImage imageNamed:@"image.ico"];
    index++;
}
@end

效果如下:

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

友情鏈接更多精彩內(nèi)容