Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UIImagePNGRepresentation slow or am I doing something wrong?

I'm working on an iPhone App that uses the camera to take pictures, then I'm saving them to the Applications Documents directory. I'm using the following code to convert the UIImage to NSData,

NSData *imageData = [NSData dataWithData:UIImagePNGRepresentation(image)];

Then I write the NSData using

[imageData writeToFile:path atomically:NO]

It all works. The problem is that UIImagePNGRepresentation() is really slow. It takes 8-9 secs on my 3G to convert the image to NSData. This seems wrong to me. Does anyone have any experience with this? Is this just slow function or am I doing something terribly wrong?

Thanks

like image 652
TheGeoff Avatar asked Aug 03 '09 20:08

TheGeoff


1 Answers

Are you sure you want to save pictures captured with the camera as PNG?

JPEG is a more appropriate format for photographs. Additionally, its likely much faster!

like image 91
Will Avatar answered Oct 20 '22 09:10

Will