Get size of a UIImage (bytes length) not height and width

后端 未结 10 2072
说谎
说谎 2020-11-28 09:00

I\'m trying to get the length of a UIImage. Not the width or height of the image, but the size of the data.

10条回答
  •  挽巷
    挽巷 (楼主)
    2020-11-28 09:54

     UIImage *img = [UIImage imageNamed:@"sample.png"];
     NSData *imgData = UIImageJPEGRepresentation(img, 1.0); 
     NSLog(@"Size of Image(bytes):%d",[imgData length]);
    

提交回复
热议问题