반응형
ALAssetRepresentation에서 XMP 메타 데이터 해석
사용자가 iOS 의 내장 Photos.app 에서 사진을 일부 변경 (자르기, 적목 제거 등)하면 해당 변경 사항이 fullResolutionImage해당 ALAssetRepresentation.
그러나, 변경 사항이 적용됩니다 thumbnail와는 fullScreenImage에 의해 반환 ALAssetRepresentation. 또한 적용된 변경 사항에 대한 정보 ALAssetRepresentation는 키를 통해의 메타 데이터 사전 에서 찾을 수 있습니다 @"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];
}
그러나이 기능은 일부 필터 (자르기, 자동 향상)에만 적용되고 적목 제거와 같은 다른 필터에는 적용되지 않습니다. 이 경우 CIFilters는 눈에 띄는 효과가 없습니다. 따라서 내 질문 :
- 적목 제거 방법을 알고있는 사람이
CIFilter있습니까? (Photos.app과 일치하는 방식입니다. 키kCIImageAutoAdjustRedEye가 있는 필터로는 충분하지 않습니다. 예를 들어 눈의 위치에 대한 매개 변수를 사용하지 않습니다.) - iOS 5에서 이러한 필터를 생성하고 적용 할 수 있습니까?
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, and free the buffer after.
NSData *adata = [[NSData alloc] initWithBytesNoCopy:buffer length:representation.size freeWhenDone:YES];
// Set up a dictionary with a UTI hint. The UTI hint identifies the type
// of image we are dealing with (that is, 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);
// Clean up memory
CFRelease(imagePropertiesDictionary);
참고 URL : https://stackoverflow.com/questions/13305020/interpret-xmp-metadata-in-alassetrepresentation
반응형
'Programming' 카테고리의 다른 글
| JQuery $ .scrollTo () 함수를 사용하여 창을 스크롤하는 방법 (0) | 2020.08.25 |
|---|---|
| Swift-시간 / 분 / 초로의 정수 변환 (0) | 2020.08.25 |
| prefetchPlugin 및 분석 도구를 사용하여 웹팩의 빌드 시간을 최적화하는 방법은 무엇입니까? (0) | 2020.08.25 |
| Xcode 7.3 자동 완성은 너무 실망 스럽습니다. (0) | 2020.08.25 |
| 교차 도메인 인증을 위해 JWT를 사용하는 싱글 사인온 플로우 (0) | 2020.08.25 |