uiimagejpegrepresentation

UIImagePickerController and the need to save the UIImage asap vs. exploiting the file backing

自作多情 提交于 2019-12-06 12:01:14
I've read uiimagepickercontroller uiimage memory and more and other relevant questions, but I can't get my head around one thing, and I wonder if there are people around here with experience on this particular aspect. In my app I let the user select an image from his library, ultimately resulting in an upload. (An interesting thing here, is that the images in there may originate from 12-megapixel high quality camera's, since e.g. iTunes happily syncs them into the phone.) For various reasons, I UIImageJPEGRepresentation the thing right away to a locally stored file. Without much thought, I

iPhone How to get image back from NSData

自古美人都是妖i 提交于 2019-12-06 05:00:37
问题 In my iPhone App I am storing image into NSData by UIImage *image =imageView.image; NSData *myData = UIImagePNGRepresentation(image); But How to get back "image" from " NSData " and I can display it again into in to UIImageView . Please Help and Suggest, Thanks. 回答1: have you tried +[UIImage imageWithData:] ? 回答2: UIImage *img=[UIImage imageWithData:data]; [yourImageView setImage:img]; 来源: https://stackoverflow.com/questions/4655174/iphone-how-to-get-image-back-from-nsdata

Why .jpeg file save via writetofile using UIImageJPEGRepresentation method have large size then UIImageWriteToSavedPhotosAlbum in ios

夙愿已清 提交于 2019-12-06 00:42:26
问题 I am trying to save an UIImage object to an .jpeg file in device and I am using this code: -(void)saveImageToDocumentsDirectory:(UIImage *)mimage withFileName:(NSString *)fileName { UIImageWriteToSavedPhotosAlbum(mimage,nil,nil,nil); NSData *dataForJPEGFile = UIImageJPEGRepresentation(mimage, 1.0); NSError *error2 = nil; if (![dataForJPEGFile writeToFile:[self getDirectoryFilePath:fileName] options:NSAtomicWrite error:&error2]) { return; } } It will save the image of .jpeg type but take too

imageWithData image size become bigger?

浪子不回头ぞ 提交于 2019-12-04 20:30:06
I create a UIimage using the imageWithData method: - (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info { UIImage *chosenImage = [info objectForKey:@"UIImagePickerControllerOriginalImage"]; NSData *data1 = UIImageJPEGRepresentation(chosenImage, 1); NSData *data2 = UIImageJPEGRepresentation(chosenImage, 0.5); NSLog(@"data1 = %lu;;;;;;;data2 = %lu",[data1 length],[data2 length]); UIImage *nimg = [UIImage imageWithData:data2]; NSData *data30 = UIImageJPEGRepresentation(nimg, 1); NSData *data31 = UIImageJPEGRepresentation(nimg, 0.8);

iPhone How to get image back from NSData

馋奶兔 提交于 2019-12-04 09:47:04
In my iPhone App I am storing image into NSData by UIImage *image =imageView.image; NSData *myData = UIImagePNGRepresentation(image); But How to get back "image" from " NSData " and I can display it again into in to UIImageView . Please Help and Suggest, Thanks. have you tried +[UIImage imageWithData:] ? UIImage *img=[UIImage imageWithData:data]; [yourImageView setImage:img]; 来源: https://stackoverflow.com/questions/4655174/iphone-how-to-get-image-back-from-nsdata

Why .jpeg file save via writetofile using UIImageJPEGRepresentation method have large size then UIImageWriteToSavedPhotosAlbum in ios

不羁岁月 提交于 2019-12-04 05:21:33
I am trying to save an UIImage object to an .jpeg file in device and I am using this code: -(void)saveImageToDocumentsDirectory:(UIImage *)mimage withFileName:(NSString *)fileName { UIImageWriteToSavedPhotosAlbum(mimage,nil,nil,nil); NSData *dataForJPEGFile = UIImageJPEGRepresentation(mimage, 1.0); NSError *error2 = nil; if (![dataForJPEGFile writeToFile:[self getDirectoryFilePath:fileName] options:NSAtomicWrite error:&error2]) { return; } } It will save the image of .jpeg type but take too much memory as compare to the UIImageWriteToSavedPhotosAlbum(mimage,nil,nil,nil) method, which saves the

What should compressionQuality be when using UIImageJPEGRepresentation?

廉价感情. 提交于 2019-12-03 01:24:49
I would like to apply a filter to a photo from the user's library then write it back to disk. I'm using UIImageJPEGRepresentation . This function takes a UIImage and a compressionQuality value between 0.0 and 1.0. Because I want to preserve the original quality, I set it to 1.0. But I found this actually creates an image file that's larger in file size than the original, somewhat significantly larger even. I noticed in Apple's Sample Photo Editing Extension app they always set the quality to 0.9. I tried that and it does output a file size close to the original photo file size. This doesn't

From the results of UIImagePickerControlleHow, how do I get JPEG with metadata included in it?

时光怂恿深爱的人放手 提交于 2019-12-02 21:23:04
On iOS 4.2 when I use UIImagePickerController to let the user select a image from the photo library these are the dictionary keys that are returned to me: 2011-03-02 13:15:59.518 xxx[15098:307] didFinishPickingMediaWithInfo: info dictionary: { UIImagePickerControllerMediaType = "public.image"; UIImagePickerControllerOriginalImage = "<UIImage: 0x3405d0>"; UIImagePickerControllerReferenceURL = "assets-library://asset/asset.JPG?id=1000000050&ext=JPG"; } Using one or more of these keys, how can I get a JPEG representation that would include the image metadata (such as exposure information and GPS

UIImageJPEGRepresentation - memory release issue

老子叫甜甜 提交于 2019-12-01 05:09:26
问题 On a iPhone app, I need to send a jpg by mail with a maximum size of 300Ko (I don't no the maximum size mail.app can have, but it's another problem). To do that, I'm trying to decrease quality until obtain an image under 300Ko. In order to obtain the good value of the quality (compressionLevel) who give me a jpg under 300Ko, I have made the following loop. It's working, but each time time the loop is executed, the memory increase of the size of the original size of my jpg (700Ko) despite the

Using ALAssetsLibrary and ALAsset take out Image as NSData

廉价感情. 提交于 2019-11-28 17:05:47
I wish to extract the image using ALAssetsLibrary and ALAsset directly in the form of a NSData object. Using a NSURL I take out the image in the following manner. NSURL *referenceURL =newURL; ALAssetsLibrary *library = [[ALAssetsLibrary alloc] init]; [library assetForURL:referenceURL resultBlock:^(ALAsset *asset) { UIImage *copyOfOriginalImage = [UIImage imageWithCGImage:[[asset defaultRepresentation] fullResolutionImage]]; } Now here we take the image as a UIImage, but I need to take the image directly as NSData. I wish to do this because (I have read that) once you take the image in UIImage,