How to get the Size (KB) of UIImage

后端 未结 2 1108
野趣味
野趣味 2021-02-07 12:05

I am getting Image from didFinishPickingMediaWithInfo.

UIImage *originalImage = (UIImage*)[info valueForKey:UIImagePickerControllerOriginalImage];
<         


        
2条回答
  •  广开言路
    2021-02-07 12:22

        UIImage *originalImage = (UIImage*)[info valueForKey:UIImagePickerControllerOriginalImage];
        NSData *imgData = UIImageJPEGRepresentation(originalImage, 1); //1 it represents the quality of the image.
        NSLog(@"Size of Image(bytes):%d",[imgData length]);
        imgData = nil;
    

提交回复
热议问题