///压缩图片 + (NSData *)imageCompressToData:(UIImage *)image{ NSData *data=UIImageJPEGRepresentation(image, 1.0); if (data.length>300*1024) { if (data.length>1024*1024) {//1M以及以上 data=UIImageJPEGRepresentation(image, 0.1); }else if (data.length>512*1024) {//0.5M-1M data=UIImageJPEGRepresentation(image, 0.5); }else if (data.length>300*1024) {//0.25M-0.5M data=UIImageJPEGRepresentation(image, 0.9); } } return data; }