how to save Image to Photos in iPhone without losing quality?

cocoa-touch, image, iphone

Solution

You need to wrap the image in a PNG representation, so that it's saved to the Photo Library in PNG format, rather than JPG format.

I used the following code based on the code from Ben Weiss: UIImageWriteToSavedPhotosAlbum saves to wrong size and quality for a side by side comparison.

// Image contains a non-compressed image stored within my Documents directory
UIImageWriteToSavedPhotosAlbum(image, nil, nil, nil);
NSData* imdata = UIImagePNGRepresentation ( image ); 
UIImage* im2 = [UIImage imageWithData:imdata]; 
UIImageWriteToSavedPhotosAlbum(im2, nil, nil, nil); 

The image will be saved in the PNG format in the Photo Library so that it can be accessed/shared later in full quality.

Problem

the quality of saved image will lose when i'm using this method ... ``` UIImage *img=imageview1.image; UIImageWriteToSavedPhotosAlbum(img,nil,nil,nil); ```

Original source

Related problems