Interpreting XMP metadata in Alassetrepresentation

Source: Internet
Author: User

When the user makes certain changes (crop, remove red-eye, ... ), on the built-in Photos.app iOS, these changes will not be applied to the

Fullresolutionimage

Returned by

Alassetrepresentation

Photo.

However, these changes are applied to the

Thumbnail

and by

Fullscreenimage

Returned by

Alassetrepresentation

.
In addition, change information about the app can be

Alassetrepresentation

Meta-data dictionary via key

@ "ADJUSTMENTXMP"

Found.

I want these changes to be applied to

Fullresolutionimage

Maintain consistency. I found in IOS6 's +

Cifilter

Of

FilterArrayFromSerializedXMP:inputImageExtent:error:

This XMP metadata can be converted to the

Cifilter

Array of:

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];
}

However, this applies only to certain filters (clipping, auto-boost), but not to others like removing red-eye. In these cases,

Cifilter

S has no visible effect. So, my question:

    • There's no one knows the way to create red-eye removal

      Cifilter

      ? (in a manner consistent with Photos.app, with the key

      Kciimageautoadjustredeye

      The filter is not enough. For example, it does not take into account the positional parameters of the eye.)

    • Is there a possible way to generate and apply these filters under iOS 5?
Answer 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);

Interpreting XMP metadata in Alassetrepresentation

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.