Edited picture issues in iOS

Source: Internet
Author: User

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

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.