开发者

Objective C - image upload optimize file size

开发者 https://www.devze.com 2023-04-01 21:45 出处:网络
I\'m able to upload an image using ASIHTTPRequest. Code is something like this. - (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {

I'm able to upload an image using ASIHTTPRequest.

Code is something like this.

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
    NSData *imageData = UIImageJPEGRepresentation(self.selectedImage.image, 0.5);

    ...
}

Is there anyway I can find out the file size of that "imageData". Basically trying to find out what file size I'm uploading and if there is an开发者_JS百科yway that I can optimize the file size if it is too large.

Thank you,

Tee


It's pretty easy to find the size: NSData supports the length method:

NSUInteger imageSize = [imageData length];

Optimization options will then depend on what your server supports

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号