// ------ 图片压缩至100K以内上传
-(NSData *)imageData:(UIImage *)myimage
{
NSData *data=UIImageJPEGRepresentation(myimage, 1.0);
if (data.length>100*1024) {
if (data.length>2*1024*1024) {//2M以及以上
data=UIImageJPEGRepresentation(myimage, 0.05);
}else if (data.length>1024*1024) {//1M-2M
data=UIImageJPEGRepresentation(myimage, 0.1);
}else if (data.length>512*1024) {//0.5M-1M
data=UIImageJPEGRepresentation(myimage, 0.2);
}else if (data.length>200*1024) {//0.25M-0.5M
data=UIImageJPEGRepresentation(myimage, 0.4);
}
}
return data;
}