I want to save the last clicked image saved in Photos gallery to document directory. How can i achieve it.?
Asked
Active
Viewed 80 times
0
-
I think you mean by memory disk space. Am I right with that assumption? The only explanation that I can think of is that images in the photos library are compressed. – ok404 Jan 15 '16 at 08:31
-
@ok404 - yes i mean by memory disk space. have you any solution for this..? – Sushobhit Jan 15 '16 at 08:43
-
Why duplicate: http://stackoverflow.com/questions/34740631/why-jpeg-file-save-via-writetofile-using-uiimagejpegrepresentation-method-have ? – Larme Jan 15 '16 at 11:06
2 Answers
0
In your code change NSData *dataForJPEGFile = UIImageJPEGRepresentation(mimage, 1.0);
to
NSData *dataForJPEGFile = UIImageJPEGRepresentation(mimage, 0.5);
This code 0.5 means 50% of your image will compress.
- (void)saveImageToDocumentsDirectory:(UIImage *)mimage withFileName:(NSString *)fileName {
NSData *dataForJPEGFile = UIImageJPEGRepresentation(mimage, 0.5);
[dataForJPEGFile writeToFile:[self getDirectoryFilePath:fileName] atomically:YES];
}

Ramesh_T
- 1,251
- 8
- 19
-
thanx for answering. but I need image with 100% quality not with 50%. – Sushobhit Jan 15 '16 at 09:10
-
0
Make sure the saved photo in your PhotosAlbum is correct size and quality. iOS has an issue, see link: UIImageWriteToSavedPhotosAlbum saves to wrong size and quality
For some pictures, the PNG format will be smaller than JPG format. You can try to save picture via UIImagePNGRepresentation.

Community
- 1
- 1

Harrison Xi
- 766
- 1
- 5
- 23