0

When I take the picture on camera, I'd like to get file size of UIImage.

-(void)imagePickerController:(UIImagePickerController*)imagePicker didFinishPickingMediaWithInfo:(NSDictionary*)info {
     UIImage *originalimage = [info objectForKey:UIImagePickerControllerOriginalImage];
     NSData *dataForPNGFile =  UIImagePNGRepresentation(originalimage);
     int fileLengthPNG = dataForPNGFile.length;
     NSLog(@"-->> fileSizePNG : [%i]", fileLengthPNG);
}

I wrote this code but the system console returned "fileSizePNG : [10550292]".
I think 10550292 bytes is too big.

It is about 10MB so I thought my code is mistake.

If you find any problems, could you please let to me?

Osushi
  • 107
  • 1
  • 2
  • 9
  • did you saved the file and checked the file size? – Giuseppe Mosca Nov 13 '12 at 15:30
  • You convert the image to a PNG to check the file size which will be probably be larger than the original JPEG in the camera roll. You will find your answer here: http://stackoverflow.com/a/7500214/418715 – Joe Nov 13 '12 at 15:34
  • Thank you everyone! I used ALAssetsLibrary after saving image. This is correct. – Osushi Nov 25 '12 at 05:35

1 Answers1

0

I'd [dataForPNGFile writeToFile:@"test.png" atomically:YES]

and then go to the actual file and look at the size of the file. Then you'll know for sure.

mprivat
  • 21,582
  • 4
  • 54
  • 64
  • The same amount of data will be written to the file, so whats the point of this? – Joe Nov 13 '12 at 18:20