uiimagepngrepresentation

Convert UIImage to base64 string in swift

空扰寡人 提交于 2020-06-12 09:05:45
问题 I'm trying to convert a UIImage to a base64 string with the goal of uploading it to a back-end server. However, the conversion code I found in this article (which should be Apple's own implementation) generates an invalid string: Convert between UIImage and Base64 string After upload, I get this image: [Failty image that is decoded from iOS converted base64 1 Instead of this: [Correct image decoded from an online base64 conversion tool2 I tested the upload results using Postman and the back

UIImagePNGRepresentation and masked images

旧城冷巷雨未停 提交于 2019-12-22 10:29:29
问题 I created a masked image using a function form an iphone blog: UIImage *imgToSave = [self maskImage:[UIImage imageNamed:@"pic.jpg"] withMask:[UIImage imageNamed:@"sd-face-mask.png"]]; Looks good in a UIImageView UIImageView *imgView = [[UIImageView alloc] initWithImage:imgToSave]; imgView.center = CGPointMake(160.0f, 140.0f); [self.view addSubview:imgView]; UIImagePNGRepresentation to save to disk : [UIImagePNGRepresentation(imgToSave) writeToFile:[self findUniqueSavePath] atomically:YES];

Memory issue in using UIImagePNGRepresentation

时光毁灭记忆、已成空白 提交于 2019-12-18 08:55:30
问题 Hi Guys I found this module to be troublesome. I import more than 100 images from Photolibrary, save them in documents directory with a different name. As expected I had a memory issue in the unusual place. It seems UIImagePNGRepresenation is caching files. So when I run the below process for 300+ images, I see "Overall bytes" in the range of 3.00 GB and crashes due to Memory (tested in allocations tool). I have pasted the code below. Is there any alternative for this code -(void)something {

Convert UIImage to NSData without using UIImagePngrepresentation or UIImageJpegRepresentation

给你一囗甜甜゛ 提交于 2019-12-17 21:52:46
问题 I Need to convert UIImage to NSData but without using UIImagePngRepresentation or UIImageJpegRepresentation , for images from photolib i can use assetlib method as mentioned here Using ALAssetsLibrary and ALAsset take out Image as NSData , but for captured image , assset url is not there hence in that case i need to convert UIImage directly to bytes with exif data , how can i accomplish this ? please help 回答1: H Bastan, Based on your comment: ...I want to save the captured image return by

UIImagePNGRepresentation issues? / Images rotated by 90 degrees

允我心安 提交于 2019-12-17 06:29:42
问题 I want to load images from UIImagePickerController, then save the selected photo to my app's document directory. UIImage *image = [info objectForKey:UIImagePickerControllerOriginalImage]; NSData *data1 = UIImagePNGRepresentation(image); NSString *fileName = "1.png"; NSString *path = //get Document path, then add fileName BOOL succ = [data1 writeToFile:path atomically:YES]; but after I save the image to my document, I found that, the image was rotated 90 degree, then I change the method

UIImagePNGRepresentation issues? / Images rotated by 90 degrees

对着背影说爱祢 提交于 2019-12-17 06:29:30
问题 I want to load images from UIImagePickerController, then save the selected photo to my app's document directory. UIImage *image = [info objectForKey:UIImagePickerControllerOriginalImage]; NSData *data1 = UIImagePNGRepresentation(image); NSString *fileName = "1.png"; NSString *path = //get Document path, then add fileName BOOL succ = [data1 writeToFile:path atomically:YES]; but after I save the image to my document, I found that, the image was rotated 90 degree, then I change the method

PNG/JPEG representation from CIImage always returns nil

坚强是说给别人听的谎言 提交于 2019-12-17 04:07:55
问题 I'm currently making a photo editing app. When a photo is selected by the user, it is automatically converted into black and white using this code: func blackWhiteImage(image: UIImage) -> Data { print("Starting black & white") let orgImg = CIImage(image: image) let bnwImg = orgImg?.applyingFilter("CIColorControls", withInputParameters: [kCIInputSaturationKey:0.0]) let outputImage = UIImage(ciImage: bnwImg!) print("Black & white complete") return UIImagePNGRepresentation(outputImage)! } The

AVCaptureStillImageOutput & UIImagePNGRepresentation

北城余情 提交于 2019-12-13 07:07:56
问题 I am having a hard time for something I think shouldn’t be so difficult, so I presume I must be looking at the problem from the wrong angle. In order to understand how AVCaptureStillImageOutput and the camera work I made a tiny app. This app is able to take a picture and save it as a PNG file (I do not want JPEG). The next time the app is launched, it checks if a file is present and if it is, the image stored inside the file is used as the background view of the app. The idea is rather simple

Convert a screen capture into a UIImage UIImagePNGRepresentation

僤鯓⒐⒋嵵緔 提交于 2019-12-12 04:16:27
问题 Below I convert a screen capture into a NSData UIImagePNGRepresentation . But how do I correct the below code and convert a screen capture into a UIImagePNGRepresentation but ensure it's using a UIImage format and not NSData ? // Take snapshot of screen var imageSnapshot: UIImage! UIGraphicsBeginImageContextWithOptions(self.view.frame.size, false, 0) self.view.drawViewHierarchyInRect(CGRect(x: 0, y: 0, width: self.view.bounds.width, height: self.view.bounds.height), afterScreenUpdates: false)

UIImagePickerControllerOriginalImage vs original asset data

梦想的初衷 提交于 2019-12-06 22:43:08
问题 In the app that I am developing, I am using an image that a user chooses from their photo albums. I need to upload a hi-res version of that photo to my server. I'm using imagePickerController and I've determined that I have 2 options use UIImage from UIImagePickerControllerOriginalImage get original asset by using UIImagePickerControllerReferenceURL and ALAssetsLibrary assetForURL (I don't like this because it prompts the user to use their current location, which I don't need) My question is.