In the development of sometimes need to get edited pictures, cut, filter and so on, then how to get it? Here are some methods of arch reference.
1. using the Fullscreenimage method of Alassetrepresentation, This method is the simplest, get the picture as seen in the photo album, because the System "album" program shows the picture is Fullscreenimage , not fullresolutionimage , but the problem with this approach is that the image resolution is only as large as the screen size, and when it comes to long graphs, it's powerless, and if we use Fullresolutionimage , you will find that the image taken is the original, not edited. Therefore, if the resolution is not considered, then this method is a good choice to get the edited picture.
2. Using the ADJUSTMENTXMP information in the picture metadata dictionary , all asset will put their relevant modification information (cut, filter, etc.) in the metadata dictionary ADJUSTMENTXMP, So we can parse out the modification information and apply it to the fullresolutionimage, so that we can get high resolution and edited pictures, even the long graph can cope with.
Alassetrepresentation *representation =[Asset defaultrepresentation]; Cgimageref Fullresimage=[representation fullresolutionimage]; NSString*adjustment = [[Representation metadata] Objectforkey:@"ADJUSTMENTXMP"]; if(Adjustment) {NSData*xmpdata =[Adjustment datausingencoding:nsutf8stringencoding]; Ciimage*image =[Ciimage Imagewithcgimage:fullresimage]; Nserror*error =Nil; Nsarray*filterarray =[Cifilter filterarrayfromserializedxmp:xmpdata Inputimageexte Nt:image.extent Error:&ERROR]; Cicontext*context =[Cicontext Contextwithoptions:nil]; if(Filterarray &&!)error) { for(Cifilter *filterinchfilterarray) {[Filter setvalue:image Forkey:kciinputimagekey]; Image=[Filter outputimage]; } fullresimage=[Context Createcgimage:image fromrect:[image extent]; }} UIImage*adjustimage =[UIImage imagewithcgimage:fullresimage scale:[representation Scale] Orientation: (uiimageorientation) [representation orientation];
Edited picture issues in iOS