Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

the quality of saved image will lose when i'm using this method ...

UIImage *img=imageview1.image;
UIImageWriteToSavedPhotosAlbum(img,nil,nil,nil);
like image 249
Naeim Fard Avatar asked Dec 29 '22 23:12

Naeim Fard


1 Answers

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.

like image 102
Paul Solt Avatar answered Jan 05 '23 17:01

Paul Solt