Reputation: 111
I used UIImageJPEGRepresentation
to get the NSData
but the file extension is .png
.
e.g.
NSData *imageData = UIImageJPEGRepresentation(anImage, compression);
[imageData writeToFile:@"abc.png" atomically:YES];
It worked, although I am not sure what I am getting. I mean is the final file still a .png
file? If I use UIImagePNGRepresentation
would it make a difference? Cheers!
Upvotes: 2
Views: 985
Reputation: 66234
If you use UIImageJPEGRepresentation
, you'll write the data in JPEG format.
Using UIImagePNGRepresentation
will write the data in PNG format.
The extension you specify only affects what applications a user might open the file in. There's no good reason to write JPEG data to a file with a .png
extension.
Upvotes: 2