0
votes

How to create a png or jpg file from a UIImage (camera/gallery), my aim isn't for saving locally I should upload this image as image to server.

tried UIImageJPEGRepresentation and UIImagePNGRepresentation but they both creates a NSData, I want pure png/swift files-images.

1
NSData has what you want. PNG & JPEG data just happens to be the byte for byte representation needed for the file. Just use the getBytes method of NSData and that's the 'file' you're after. I don't think there's any other iOS methods to do what you want more easily.BitBank

1 Answers

0
votes

For me, I'll encode the image and send the encoded string to server, then only convert it back and save it as whatever format you like.

You can refer "this link" to know more about encoding the image.