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

一、引言

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

1.CGImageSource.h:負責讀取圖片數(shù)據(jù)隘世。

2.CGImageDestination.h:負責寫入圖片數(shù)據(jù)可柿。

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

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

5.ImageIOBase.h:預處理邏輯复斥,無需關心。

二械媒、CGImageSource詳解

CGImageSource類的主要作用是用來讀取圖片數(shù)據(jù)目锭,在平時開發(fā)中,關于圖片我們使用的最多的可能是UIImage類纷捞,UIImage是iOS系統(tǒng)UI系統(tǒng)中用于構建圖像對象的類痢虹,但是其中只有圖像數(shù)據(jù),實際上一個圖片文件中存儲的除了圖片數(shù)據(jù)外主儡,還有一些地理位置奖唯、設備類型、時間等信息,除此之外早龟,一個圖片文件中可能存儲的也不只一張圖像(例如gif文件)。CGImageSource就是這樣的一個抽象圖片數(shù)據(jù)示例权逗,從其中可以獲取到我們所關心的所有數(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對象
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];

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

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

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

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

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

//獲取CGImageSource類在CoreFundation框架中的id
CFTypeID CGImageSourceGetTypeID (void);
//獲取所支持的圖片格式數(shù)組
CFArrayRef __nonnull CGImageSourceCopyTypeIdentifiers(void);
//獲取CGImageSource對象的圖片格式
CFStringRef __nullable CGImageSourceGetType(CGImageSourceRef __nonnull isrc);
//獲取CGImageSource中的圖片張數(shù) 不包括縮略圖
size_t CGImageSourceGetCount(CGImageSourceRef __nonnull isrc);
//獲取CGImageSource的文件信息
/*
字典參數(shù)可配置的鍵值對與創(chuàng)建CGImageSource所傳參數(shù)意義一致
返回的字典中的鍵值意義后面介紹
*/
CFDictionaryRef __nullable CGImageSourceCopyProperties(CGImageSourceRef __nonnull isrc, CFDictionaryRef __nullable options);
//獲取CGImageSource中某個圖像的附加數(shù)據(jù)
/*
index參數(shù)設置獲取第幾張圖像 options參數(shù)可配置的鍵值對與創(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);
//刪除一個指定索引圖像的緩存
void CGImageSourceRemoveCacheAtIndex(CGImageSourceRef __nonnull isrc, size_t index);
//獲取某一幀圖片的縮略圖
CGImageRef __nullable CGImageSourceCreateThumbnailAtIndex(CGImageSourceRef __nonnull isrc, size_t index, CFDictionaryRef __nullable options);
//創(chuàng)建一個空的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);
//獲取當前CGImageSource的狀態(tài)
/*
CGImageSourceStatus枚舉意義:
typedef CF_ENUM(int32_t, CGImageSourceStatus) {
    kCGImageStatusUnexpectedEOF = -5, //文件結尾出錯
    kCGImageStatusInvalidData = -4,   //數(shù)據(jù)無效
    kCGImageStatusUnknownType = -3,   //未知的圖片類型
    kCGImageStatusReadingHeader = -2, //讀標題過程中
    kCGImageStatusIncomplete = -1,    //操作不完整
    kCGImageStatusComplete = 0        //操作完整
};
*/
CGImageSourceStatus CGImageSourceGetStatus(CGImageSourceRef __nonnull isrc);
//同上,獲取某一個圖片的狀態(tài)
CGImageSourceStatus CGImageSourceGetStatusAtIndex(CGImageSourceRef __nonnull isrc, size_t index);

三起暮、CGImageDestination詳解

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

//創(chuàng)建存儲路徑
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對象
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ù)消費器,方法如下:

//將圖片數(shù)據(jù)寫入數(shù)據(jù)消費者
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ù)據(jù)的文件格式系吭,必須為ImageIO框架所支持的格式,前面有方法可以獲取所有支持的格式颗品,還有一點肯尺,這3個寫入方法的中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);
//設置圖片文件屬性
/*
可以設置的鍵值對意義如下:
const CFStringRef kCGImageDestinationLossyCompressionQuality; //設置壓縮質量 0-1之間的cfnumberref值
const CFStringRef kCGImageDestinationBackgroundColor;  //將圖片數(shù)據(jù)寫為無alpha通道時的默認背景色 cgcolor值
*/
void CGImageDestinationSetProperties(CGImageDestinationRef __nonnull idst, CFDictionaryRef __nullable properties);
//向CGImageDestination中添加一張圖片 其中的option參數(shù)意義和上面一致,設置此圖片的質量與無alpha默認背景色
void CGImageDestinationAddImage(CGImageDestinationRef __nonnull idst, CGImageRef __nonnull image, CFDictionaryRef __nullable properties);
//通過CGImageSource對象來向CGImageDestination中添加圖片
void CGImageDestinationAddImageFromSource(CGImageDestinationRef __nonnull idst, CGImageSourceRef __nonnull isrc, size_t index, CFDictionaryRef __nullable properties);
//進行寫入操作 執(zhí)行此方法后 不可以在寫入其他信息
bool CGImageDestinationFinalize(CGImageDestinationRef __nonnull idst);
//添加圖片元信息
void CGImageDestinationAddImageAndMetadata(CGImageDestinationRef __nonnull idst, CGImageRef __nonnull image, CGImageMetadataRef __nullable metadata, CFDictionaryRef __nullable options);
//將CGImageSource信息拷貝進CGImageDestination
/*
options參數(shù)可以用來添加元信息
*/
bool CGImageDestinationCopyImageSource(CGImageDestinationRef __nonnull idst, CGImageSourceRef __nonnull isrc, CFDictionaryRef __nullable options, __nullable CFErrorRef * __nullable err);

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

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

四、關于CGImageMetadata

前面我們很多次提到元數(shù)據(jù),CGImageMetadata類就是元數(shù)據(jù)的抽象寨昙,其中封裝了一些方法供開發(fā)者讀取或寫入元數(shù)據(jù)信息。奇怪的是Apple的官方文檔與API文檔中并沒有CGImageMetadata的介紹與解釋掀亩,博客中本部分的內容舔哪,多出自我的理解,有疏漏和不對的地方槽棍,清楚的朋友可以指點與建議捉蚤。

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

上面創(chuàng)建CGImageMetadataTag的方法中豌拙,xmlns設置命名空間陕悬,必須使用一個預定義的命名空間或者自定義的命名空間,對于自定義的命名空間按傅,必須遵守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設置命名空間縮寫或前綴,同樣一些公用的前綴定義如下:

//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設置對應值的類型唯绍,其是一個CGImageMetadataType類型的枚舉拼岳,意義如下:

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

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

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

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

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

五况芒、CGImageProperties中定義的字典意義

前面提到的CGImageSourceCopyProperties方法與CGImageSourceCopyPropertiesAtIndex方法都會返回一個字典惜纸,字典中可能包含如下有意義的鍵:

//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;
//佳能相機信息字典
const CFStringRef kCGImagePropertyMakerCanonDictionary;
//尼康相機信息字典
const CFStringRef kCGImagePropertyMakerNikonDictionary;
//柯尼卡相機信息字典
const CFStringRef kCGImagePropertyMakerMinoltaDictionary;
//富士相機信息字典
const CFStringRef kCGImagePropertyMakerFujiDictionary;
//奧林巴斯相機信息字典
const CFStringRef kCGImagePropertyMakerOlympusDictionary;
//賓得相機信息字典
const CFStringRef kCGImagePropertyMakerPentaxDictionary;
//對應Photoshop相片的信息字典
const CFStringRef kCGImageProperty8BIMDictionary;
//NDG信息字典
const CFStringRef kCGImagePropertyDNGDictionary ;
//ExifAux信息字典
const CFStringRef kCGImagePropertyExifAuxDictionary;
//OpenEXR信息字典
const CFStringRef kCGImagePropertyOpenEXRDictionary;
//Apple相機信息字典
const CFStringRef kCGImagePropertyMakerAppleDictionary ;

CGImageSourceCopyProperties方法返回的字典中還可能會有如下一個特殊的鍵:

//對應文件大小
const CFStringRef kCGImagePropertyFileSize;

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

//像素高度
const CFStringRef kCGImagePropertyPixelHeight;
//像素寬度
const CFStringRef kCGImagePropertyPixelWidth;
//DPI高度
const CFStringRef kCGImagePropertyDPIHeight;
//DPI寬度
const CFStringRef kCGImagePropertyDPIWidth;
//顏色位數(shù)
const CFStringRef kCGImagePropertyDepth;
//圖片的顯示方向
/*
對應Number值
 *   1  =  左上到右下.  
 *   2  =  右上到左下.  
 *   3  =  右下到左上.
 *   4  =  左下到右上.  
 *   5  =  行列置換 左上到右下.  
 *   6  =  行列置換 右上到左下.  
 *   7  =  行列置換 右下到左上.  
 *   8  =  行列置換 左下到右上.
*/
const CFStringRef kCGImagePropertyOrientation;
//顏色是否支持浮點數(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;
//相機設備名
const CFStringRef kCGImagePropertyTIFFMake;
//相機設備模式
const CFStringRef kCGImagePropertyTIFFModel;
//圖片方向
const CFStringRef kCGImagePropertyTIFFOrientation;
//橫向每個分辨位的像素數(shù)
const CFStringRef kCGImagePropertyTIFFXResolution;
//縱向每個分辨位的像素數(shù)
const CFStringRef kCGImagePropertyTIFFYResolution;
//分辨率單位
const CFStringRef kCGImagePropertyTIFFResolutionUnit;
//創(chuàng)建圖像的軟件名稱和版本
const CFStringRef kCGImagePropertyTIFFSoftware;
//transform函數(shù)
const CFStringRef kCGImagePropertyTIFFTransferFunction;
//日期時間
const CFStringRef kCGImagePropertyTIFFDateTime;
//作者
const CFStringRef kCGImagePropertyTIFFArtist;
//創(chuàng)建圖片的電腦系統(tǒng)
const CFStringRef kCGImagePropertyTIFFHostComputer;
//公司信息
const CFStringRef kCGImagePropertyTIFFCopyright;
//圖片的白點
const CFStringRef kCGImagePropertyTIFFWhitePoint;
//圖像的原色色度
const CFStringRef kCGImagePropertyTIFFPrimaryChromaticities;
//圖片的瓦片寬度
const CFStringRef kCGImagePropertyTIFFTileWidth;
//圖片的瓦片高度
const CFStringRef kCGImagePropertyTIFFTileLength;

kCGImagePropertyJFIFDictionary對應的字典中可能包含如下意義的鍵:

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

kCGImagePropertyExifDictionary對應的字典中可能包含如下意義的鍵 :

//曝光時間
const CFStringRef kCGImagePropertyExifExposureTime;
//ExifNumber
const CFStringRef kCGImagePropertyExifFNumber;
//曝光程序
const CFStringRef kCGImagePropertyExifExposureProgram;
//每個通道的光譜靈敏度
const CFStringRef kCGImagePropertyExifSpectralSensitivity;
//ISO速度等級
const CFStringRef kCGImagePropertyExifISOSpeedRatings;
//ExifOECF
const CFStringRef kCGImagePropertyExifOECF;
//靈敏類型
const CFStringRef kCGImagePropertyExifSensitivityType;
//輸出靈敏標準
const CFStringRef kCGImagePropertyExifStandardOutputSensitivity;
//推薦曝光指數(shù)
const CFStringRef kCGImagePropertyExifRecommendedExposureIndex;
//ISO速率
const CFStringRef kCGImagePropertyExifISOSpeed;
const CFStringRef kCGImagePropertyExifISOSpeedLatitudeyyy;
const CFStringRef kCGImagePropertyExifISOSpeedLatitudezzz;
//Exif版本
const CFStringRef kCGImagePropertyExifVersion;
//原始日期時間
const CFStringRef kCGImagePropertyExifDateTimeOriginal;
//數(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;
//測光模式
const CFStringRef kCGImagePropertyExifMeteringMode;
//光源
const CFStringRef kCGImagePropertyExifLightSource;
//拍攝時的閃光狀態(tài)
const CFStringRef kCGImagePropertyExifFlash;
//焦距
const CFStringRef kCGImagePropertyExifFocalLength;
//主體區(qū)域
const CFStringRef kCGImagePropertyExifSubjectArea;
//相機制造商指定的信息
const CFStringRef kCGImagePropertyExifMakerNote;
//用戶信息
const CFStringRef kCGImagePropertyExifUserComment;
//日期和時間標記的秒分數(shù)
const CFStringRef kCGImagePropertyExifSubsecTime;
//原始時間
const CFStringRef kCGImagePropertyExifSubsecTimeOriginal;
//數(shù)字時間
const CFStringRef kCGImagePropertyExifSubsecTimeDigitized;
//FlashPix版本信息
const CFStringRef kCGImagePropertyExifFlashPixVersion;
//色彩空間
const CFStringRef kCGImagePropertyExifColorSpace;
//X方向像素
const CFStringRef kCGImagePropertyExifPixelXDimension;
//Y方向像素
const CFStringRef kCGImagePropertyExifPixelYDimension;
//與圖像相關的聲音文件
const CFStringRef kCGImagePropertyExifRelatedSoundFile;
//FlashEnergy
const CFStringRef kCGImagePropertyExifFlashEnergy;
//FrequencyResponse
const CFStringRef kCGImagePropertyExifSpatialFrequencyResponse;
//像素數(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;
//對圖像數(shù)據(jù)進行特殊渲染
const CFStringRef kCGImagePropertyExifCustomRendered;
//曝光模式設置
const CFStringRef kCGImagePropertyExifExposureMode;
//白平衡模式
const CFStringRef kCGImagePropertyExifWhiteBalance;
//數(shù)字變焦比
const CFStringRef kCGImagePropertyExifDigitalZoomRatio;
//35毫米膠片的等效焦距
const CFStringRef kCGImagePropertyExifFocalLenIn35mmFilm;
//場景捕捉類型(標準,景觀绝骚,肖像耐版,夜晚)
const CFStringRef kCGImagePropertyExifSceneCaptureType;
//圖像增益
const CFStringRef kCGImagePropertyExifGainControl;
//圖像對比度
const CFStringRef kCGImagePropertyExifContrast;
//圖像飽和度
const CFStringRef kCGImagePropertyExifSaturation;
//圖像銳度
const CFStringRef kCGImagePropertyExifSharpness;
//拍攝條件
const CFStringRef kCGImagePropertyExifDeviceSettingDescription;
//主體距離
const CFStringRef kCGImagePropertyExifSubjectDistRange;
//圖像的唯一標識
const CFStringRef kCGImagePropertyExifImageUniqueID;
//相機所有者
const CFStringRef kCGImagePropertyExifCameraOwnerName;
//相機序列號
const CFStringRef kCGImagePropertyExifBodySerialNumber;
//透鏡規(guī)格信息
const CFStringRef kCGImagePropertyExifLensSpecification;
//透鏡制造商名稱
const CFStringRef kCGImagePropertyExifLensMake;
//透鏡模式
const CFStringRef kCGImagePropertyExifLensModel;
//透鏡序列號
const CFStringRef kCGImagePropertyExifLensSerialNumber;
//伽馬設置
const CFStringRef kCGImagePropertyExifGamma;

kCGImagePropertyExifAuxDictionary對應的字典中可能包含的鍵定義如下:

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

kCGImagePropertyGIFDictionary對應的字典中可能包含的鍵定義如下:

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

kCGImagePropertyPNGDictionary對應的字典中可能包含的鍵定義如下:

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

kCGImagePropertyGPSDictionary對應的字典中可能包含的鍵定義如下:

//GPS版本
const CFStringRef kCGImagePropertyGPSVersion;
//緯度是南緯或北緯
const CFStringRef kCGImagePropertyGPSLatitudeRef;
//緯度
const CFStringRef kCGImagePropertyGPSLatitude;
//經(jīng)度是東經(jīng)或西經(jīng)
const CFStringRef kCGImagePropertyGPSLongitudeRef;
//經(jīng)度
const CFStringRef kCGImagePropertyGPSLongitude;
//海拔標準
const CFStringRef kCGImagePropertyGPSAltitudeRef;
//海拔高度
const CFStringRef kCGImagePropertyGPSAltitude;
//時間戳
const CFStringRef kCGImagePropertyGPSTimeStamp;
//測量GPS的衛(wèi)星
const CFStringRef kCGImagePropertyGPSSatellites;
//GPS狀態(tài)
const CFStringRef kCGImagePropertyGPSStatus;
//測量模式
const CFStringRef kCGImagePropertyGPSMeasureMode;
//精度數(shù)據(jù)
const CFStringRef kCGImagePropertyGPSDOP;
//速度標準
const CFStringRef kCGImagePropertyGPSSpeedRef;
//速度
const CFStringRef kCGImagePropertyGPSSpeed;
//運動方向參考
const CFStringRef kCGImagePropertyGPSTrackRef;
//運動方向
const CFStringRef kCGImagePropertyGPSTrack;
//位置方向參考
const CFStringRef kCGImagePropertyGPSImgDirectionRef;
//位置方向
const CFStringRef kCGImagePropertyGPSImgDirection;
//地圖測量數(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;
//日期時間
const CFStringRef kCGImagePropertyGPSDateStamp;
//校正信息
const CFStringRef kCGImagePropertyGPSDifferental;
//錯誤信息
const CFStringRef kCGImagePropertyGPSHPositioningError;

kCGImagePropertyIPTCDictionary對應的字典中可能包含的鍵定義如下:

//對象類型
const CFStringRef kCGImagePropertyIPTCObjectTypeReference;
//對象屬性
const CFStringRef kCGImagePropertyIPTCObjectAttributeReference;
//對象名稱
const CFStringRef kCGImagePropertyIPTCObjectName;
//編輯狀態(tài)
const CFStringRef kCGImagePropertyIPTCEditStatus;
//更新狀態(tài)
const CFStringRef kCGImagePropertyIPTCEditorialUpdate;
//緊急等級
const CFStringRef kCGImagePropertyIPTCUrgency;
//主體
const CFStringRef kCGImagePropertyIPTCSubjectReference;
//類別
const CFStringRef kCGImagePropertyIPTCCategory;
//補充類別
const CFStringRef kCGImagePropertyIPTCSupplementalCategory;
//Fixture標識
const CFStringRef kCGImagePropertyIPTCFixtureIdentifier;
//關鍵字
const CFStringRef kCGImagePropertyIPTCKeywords;
//內容定位碼
const CFStringRef kCGImagePropertyIPTCContentLocationCode;
//內容位置名稱
const CFStringRef kCGImagePropertyIPTCContentLocationName;
//圖像使用的最早日期
const CFStringRef kCGImagePropertyIPTCReleaseDate;
//圖像使用的最早時間
const CFStringRef kCGImagePropertyIPTCReleaseTime;
//最后一次使用日期
const CFStringRef kCGImagePropertyIPTCExpirationDate;
//最后一次使用時間
const CFStringRef kCGImagePropertyIPTCExpirationTime;
//圖像使用的特別說明
const CFStringRef kCGImagePropertyIPTCSpecialInstructions;
//建議行為
const CFStringRef kCGImagePropertyIPTCActionAdvised;
//服務參考
const CFStringRef kCGImagePropertyIPTCReferenceService;
//日期參考
const CFStringRef kCGImagePropertyIPTCReferenceDate;
//參考碼
const CFStringRef kCGImagePropertyIPTCReferenceNumber;
//創(chuàng)建日期
const CFStringRef kCGImagePropertyIPTCDateCreated;
//創(chuàng)建時間
const CFStringRef kCGImagePropertyIPTCTimeCreated;
//數(shù)字創(chuàng)建日期
const CFStringRef kCGImagePropertyIPTCDigitalCreationDate;
//數(shù)字創(chuàng)建時間
const CFStringRef kCGImagePropertyIPTCDigitalCreationTime;
//原始程序
const CFStringRef kCGImagePropertyIPTCOriginatingProgram;
//程序版本
const CFStringRef kCGImagePropertyIPTCProgramVersion;
圖像的編輯周期(早晨,晚上或兩者)皮壁。
const CFStringRef kCGImagePropertyIPTCObjectCycle;
//不想創(chuàng)建者名稱
const CFStringRef kCGImagePropertyIPTCByline;
//圖像創(chuàng)建標題
const CFStringRef kCGImagePropertyIPTCBylineTitle;
//城市信息
const CFStringRef kCGImagePropertyIPTCCity;
//城市內位置
const CFStringRef kCGImagePropertyIPTCSubLocation;
//省份
const CFStringRef kCGImagePropertyIPTCProvinceState;
//國家編碼
const CFStringRef kCGImagePropertyIPTCCountryPrimaryLocationCode;
//國家名稱
const CFStringRef kCGImagePropertyIPTCCountryPrimaryLocationName;
//OriginalTransmission參考
const CFStringRef kCGImagePropertyIPTCOriginalTransmissionReference;
//圖像內容摘要
const CFStringRef kCGImagePropertyIPTCHeadline;
//提供圖像服務的名稱
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;
//星級
const CFStringRef kCGImagePropertyIPTCStarRating;
//聯(lián)系人詳細信息
const CFStringRef kCGImagePropertyIPTCCreatorContactInfo;
//圖像使用權限
const CFStringRef kCGImagePropertyIPTCRightsUsageTerms;
//場景代碼
const CFStringRef kCGImagePropertyIPTCScene;

上面的kCGImagePropertyIPTCCreatorContactInfo對應的字典中鍵的定義如下:

//聯(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對應的字典中可能包含的鍵定義如下:

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

kCGImagePropertyDNGDictionary對應的字典中可能包含的鍵定義如下:

//DNG版本
const CFStringRef  kCGImagePropertyDNGVersion;
//兼容的最老版本
const CFStringRef  kCGImagePropertyDNGBackwardVersion;
//攝像機模型
const CFStringRef  kCGImagePropertyDNGUniqueCameraModel;
const CFStringRef  kCGImagePropertyDNGLocalizedCameraModel;
//相機序列碼
const CFStringRef  kCGImagePropertyDNGCameraSerialNumber;
//鏡頭信息
const CFStringRef  kCGImagePropertyDNGLensInfo;
//黑度等級
const CFStringRef  kCGImagePropertyDNGBlackLevel;
//白度等級
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對應的字典中可能包含的鍵定義如下:

//相機信息
const CFStringRef  kCGImagePropertyCIFFDescription;
//固件版本
const CFStringRef  kCGImagePropertyCIFFFirmware;
//所有者名稱
const CFStringRef  kCGImagePropertyCIFFOwnerName;
//圖片名
const CFStringRef  kCGImagePropertyCIFFImageName;
//圖片文件名
const CFStringRef  kCGImagePropertyCIFFImageFileName;
//曝光方式
const CFStringRef  kCGImagePropertyCIFFReleaseMethod;
//曝光時間
const CFStringRef  kCGImagePropertyCIFFReleaseTiming;
//RecordID
const CFStringRef  kCGImagePropertyCIFFRecordID;
//曝光時間
const CFStringRef  kCGImagePropertyCIFFSelfTimingTime;
//相機序列號
const CFStringRef  kCGImagePropertyCIFFCameraSerialNumber;
//圖片編碼
const CFStringRef  kCGImagePropertyCIFFImageSerialNumber;
//驅動模式
const CFStringRef  kCGImagePropertyCIFFContinuousDrive);
//焦點模式
const CFStringRef  kCGImagePropertyCIFFFocusMode;
//測量模式
const CFStringRef  kCGImagePropertyCIFFMeteringMode;
//曝光模式
const CFStringRef  kCGImagePropertyCIFFShootingMode;
//透鏡模式
const CFStringRef  kCGImagePropertyCIFFLensModel;
//最長鏡頭長度
const CFStringRef  kCGImagePropertyCIFFLensMaxMM;
//最短鏡頭長度
const CFStringRef  kCGImagePropertyCIFFLensMinMM;
//白平衡等級
const CFStringRef  kCGImagePropertyCIFFWhiteBalanceIndex;
//曝光補償
const CFStringRef  kCGImagePropertyCIFFFlashExposureComp;
//實測曝光值
const CFStringRef  kCGImagePropertyCIFFMeasuredEV);

六椭更、ImageIO框架在實際開發(fā)中的幾個應用

1.顯示特殊格式的圖片

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

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ù)碼相機拍攝圖片的地理位置、時間等信息

3.對相冊中圖片的地理位置扔水,時間等信息進行自定義修改痛侍。

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

5.展示GIF動圖

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

6.漸進渲染大圖

漸進渲染技術在對加載大圖片時特別重要主届,你應該使用過地圖軟件赵哲,地圖視圖在加載時是局部進行加載,當移動或者放大時君丁,地圖會一部分一部分的漸進進行加載枫夺,使用ImageIO框架可以實現(xiàn)大圖漸進渲染的效果,一般在對大圖片進行網(wǎng)絡請求時绘闷,可以獲取一部分數(shù)據(jù)就加載一部分數(shù)據(jù)橡庞,為了便于演示,博客中使用定時器來默認網(wǎng)絡返回數(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

效果如下:

最后編輯于
?著作權歸作者所有,轉載或內容合作請聯(lián)系作者
  • 序言:七十年代末扒最,一起剝皮案震驚了整個濱河市,隨后出現(xiàn)的幾起案子华嘹,更是在濱河造成了極大的恐慌吧趣,老刑警劉巖,帶你破解...
    沈念sama閱讀 219,039評論 6 508
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件除呵,死亡現(xiàn)場離奇詭異再菊,居然都是意外死亡,警方通過查閱死者的電腦和手機颜曾,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 93,426評論 3 395
  • 文/潘曉璐 我一進店門纠拔,熙熙樓的掌柜王于貴愁眉苦臉地迎上來,“玉大人泛豪,你說我怎么就攤上這事稠诲。” “怎么了诡曙?”我有些...
    開封第一講書人閱讀 165,417評論 0 356
  • 文/不壞的土叔 我叫張陵臀叙,是天一觀的道長。 經(jīng)常有香客問我价卤,道長劝萤,這世上最難降的妖魔是什么? 我笑而不...
    開封第一講書人閱讀 58,868評論 1 295
  • 正文 為了忘掉前任慎璧,我火速辦了婚禮床嫌,結果婚禮上,老公的妹妹穿的比我還像新娘胸私。我一直安慰自己厌处,他們只是感情好,可當我...
    茶點故事閱讀 67,892評論 6 392
  • 文/花漫 我一把揭開白布岁疼。 她就那樣靜靜地躺著阔涉,像睡著了一般。 火紅的嫁衣襯著肌膚如雪。 梳的紋絲不亂的頭發(fā)上瑰排,一...
    開封第一講書人閱讀 51,692評論 1 305
  • 那天贯要,我揣著相機與錄音,去河邊找鬼凶伙。 笑死郭毕,一個胖子當著我的面吹牛,可吹牛的內容都是我干的函荣。 我是一名探鬼主播,決...
    沈念sama閱讀 40,416評論 3 419
  • 文/蒼蘭香墨 我猛地睜開眼扳肛,長吁一口氣:“原來是場噩夢啊……” “哼傻挂!你這毒婦竟也來了?” 一聲冷哼從身側響起挖息,我...
    開封第一講書人閱讀 39,326評論 0 276
  • 序言:老撾萬榮一對情侶失蹤金拒,失蹤者是張志新(化名)和其女友劉穎,沒想到半個月后套腹,有當?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體绪抛,經(jīng)...
    沈念sama閱讀 45,782評論 1 316
  • 正文 獨居荒郊野嶺守林人離奇死亡,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內容為張勛視角 年9月15日...
    茶點故事閱讀 37,957評論 3 337
  • 正文 我和宋清朗相戀三年电禀,在試婚紗的時候發(fā)現(xiàn)自己被綠了幢码。 大學時的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片。...
    茶點故事閱讀 40,102評論 1 350
  • 序言:一個原本活蹦亂跳的男人離奇死亡尖飞,死狀恐怖症副,靈堂內的尸體忽然破棺而出,到底是詐尸還是另有隱情政基,我是刑警寧澤贞铣,帶...
    沈念sama閱讀 35,790評論 5 346
  • 正文 年R本政府宣布,位于F島的核電站沮明,受9級特大地震影響辕坝,放射性物質發(fā)生泄漏。R本人自食惡果不足惜荐健,卻給世界環(huán)境...
    茶點故事閱讀 41,442評論 3 331
  • 文/蒙蒙 一酱畅、第九天 我趴在偏房一處隱蔽的房頂上張望。 院中可真熱鬧摧扇,春花似錦圣贸、人聲如沸。這莊子的主人今日做“春日...
    開封第一講書人閱讀 31,996評論 0 22
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽。三九已至,卻和暖如春用含,著一層夾襖步出監(jiān)牢的瞬間矮慕,已是汗流浹背。 一陣腳步聲響...
    開封第一講書人閱讀 33,113評論 1 272
  • 我被黑心中介騙來泰國打工啄骇, 沒想到剛下飛機就差點兒被人妖公主榨干…… 1. 我叫王不留痴鳄,地道東北人。 一個月前我還...
    沈念sama閱讀 48,332評論 3 373
  • 正文 我出身青樓缸夹,卻偏偏與公主長得像痪寻,于是被迫代替她去往敵國和親。 傳聞我的和親對象是個殘疾皇子虽惭,可洞房花燭夜當晚...
    茶點故事閱讀 45,044評論 2 355