Objective C - 图片上传优化文件大小
我可以使用 ASIHTTPRequest 上传图像。
代码是这样的。
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
NSData *imageData = UIImageJPEGRepresentation(self.selectedImage.image, 0.5);
...
}
无论如何,我可以找出该“imageData”的文件大小吗?基本上试图找出我上传的文件大小,以及如果文件太大,我是否可以优化文件大小。
谢谢你,
球座
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 anyway that I can optimize the file size if it is too large.
Thank you,
Tee
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
找到大小非常容易:NSData 支持长度方法:
优化选项将取决于您的服务器支持的内容
It's pretty easy to find the size: NSData supports the length method:
Optimization options will then depend on what your server supports