I am taking an image from UIImageView and this image I am creating programmatically.Now I want to save this image in jpg or png format in Resource folder.Can anyone know how can I save image in jpg or png format?
Thanks in advance!
Go to File and select Export. Next, go to the Format menu and choose JPG as the new file format for the selected photos. Finally, click Save to convert and save the pictures.
Screenshots i.e pictures of the iPhone's screen, are taken in PNG format. It's a pretty universal format that all computers and most all devices understand and can display.
Go to File > Save as and open the Save as type drop-down menu. You can then select JPEG and PNG, as well as TIFF, GIF, HEIC, and multiple bitmap formats. Save the file to your computer and it will convert.
This should work:
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask, YES);
NSString *docs = [paths objectAtIndex:0];
NSString* path = [docs stringByAppendingFormat:@"/image1.jpg"];
NSData* imageData = [NSData dataWithData:UIImageJPEGRepresentation(imageView.image, .8)];
NSError *writeError = nil;
if(![imageData writeToFile:path options:NSDataWritingAtomic error:&writeError]) {
NSLog(@"%@: Error saving image: %@", [self class], [writeError localizedDescription]);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With