解讀XMP中繼資料中ALAssetRepresentation

來源:互聯網
上載者:User

標籤:

 

當使用者進行某些更改(裁剪,消除紅眼,...),在內建 Photos.app iOS上,這些更改將不會應用到由相應

fullResolutionImage

返回的

ALAssetRepresentation

照片.

但是,這些更改應用到

thumbnail

並由

fullScreenImage

返回的

ALAssetRepresentation

.
此外,有關應用的更改資訊可以在

ALAssetRepresentation

的中繼資料字典通過key

@"AdjustmentXMP"

發現.

我想這些更改應用到

fullResolutionImage

自己保持一致性.我發現在 iOS6的+

CIFilter

的

filterArrayFromSerializedXMP: inputImageExtent:error:

可以在此XMP中繼資料轉換的

CIFilter

數組的:

ALAssetRepresentation *rep;
NSString *xmpString = rep.metadata[@"AdjustmentXMP"];
NSData *xmpData = [xmpString dataUsingEncoding:NSUTF8StringEncoding];

CIImage *image = [CIImage imageWithCGImage:rep.fullResolutionImage];

NSError *error = nil;
NSArray *filterArray = [CIFilter filterArrayFromSerializedXMP:xmpData
inputImageExtent:image.extent
error:&error];
if (error) {
NSLog(@"Error during CIFilter creation: %@", [error localizedDescription]);
}

CIContext *context = [CIContext contextWithOptions:nil];

for (CIFilter *filter in filterArray) {
[filter setValue:image forKey:kCIInputImageKey];
image = [filter outputImage];
}

 

然而,這僅適用於某些過濾器(裁剪,自動提升),但不是為別人像去除紅眼.在這些情況下,

CIFilter

s有沒有可見的效果.因此,我的問題:

  • 有沒有人知道的方式來建立紅眼消除

    CIFilter

    ? (在與Photos.app一致的方式,與關鍵

    kCIImageAutoAdjustRedEye

    該過濾器是不夠的.例如,它沒有考慮對眼睛的位置參數.)

  • 有沒有一種可能的iOS 5下產生並應用這些過濾器?
   解答  Rank --  0

 

ALAssetRepresentation* representation = [[self assetAtIndex:index] defaultRepresentation];
// create a buffer to hold the data for the asset‘s image
uint8_t *buffer = (Byte*)malloc(representation.size);// copy the data from the asset into the buffer
NSUInteger length = [representation getBytes:buffer fromOffset: 0.0 length:representation.size error:nil];

if (length==0) return nil;

// convert the buffer into a NSData object, free the buffer after

NSData *adata = [[NSData alloc] initWithBytesNoCopy:buffer length:representation.size freeWhenDone:YES];

// setup a dictionary with a UTI hint. The UTI hint identifies the type of image we are dealing with (ie. a jpeg, png, or a possible RAW file)

// specify the source hint

NSDictionary* sourceOptionsDict = [NSDictionary dictionaryWithObjectsAndKeys:

(id)[representation UTI] ,kCGImageSourceTypeIdentifierHint,

nil];

// create a CGImageSource with the NSData. A image source can contain x number of thumbnails and full images.

CGImageSourceRef sourceRef = CGImageSourceCreateWithData((CFDataRef) adata, (CFDictionaryRef) sourceOptionsDict);

[adata release];

CFDictionaryRef imagePropertiesDictionary;

// get a copy of the image properties from the CGImageSourceRef

imagePropertiesDictionary = CGImageSourceCopyPropertiesAtIndex(sourceRef,0, NULL);

CFNumberRef imageWidth = (CFNumberRef)CFDictionaryGetValue(imagePropertiesDictionary, kCGImagePropertyPixelWidth);

CFNumberRef imageHeight = (CFNumberRef)CFDictionaryGetValue(imagePropertiesDictionary, kCGImagePropertyPixelHeight);

int w = 0;

int h = 0;

CFNumberGetValue(imageWidth, kCFNumberIntType, &w);

CFNumberGetValue(imageHeight, kCFNumberIntType, &h);

// cleanup memory

CFRelease(imagePropertiesDictionary);

    

解讀XMP中繼資料中ALAssetRepresentation

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.