How to convert jpg images to png images from server

ios, iphone, objective-c

Solution

Please try below code:

UIImage *img; // Your image coming from server
NSData *pngData = UIImagePNGRepresentation(img); // Convert it in to PNG data
UIImage *pngImage = [UIImage imageWithData:pngData]; // Result image

Problem

Hi can anyone help in converting jpg images fetching from server into png images in objective-c. Actually the problem is through the app,we are sharing images on facebook,but when jpg image is uploading in server,the image is not shared in facebook. UIImage *image = [UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:self.imageurl]]]; I have to convert the imageurl to png format.

Original source