//压缩图片 解决图片过多 内存过大图片
+ (UIImage *)newImageWithImage:(UIImage *)image{内存
//实现等比例缩放it
float hfactor = image.size.width/KWidth;io
float vfactor = image.size.height/KHeight;float
float factor = fmaxf(hfactor, vfactor);im
//画布大小new
CGFloat newWidth = image.size.width/factor;压缩
CGFloat newHeight = image.size.height/factor;return
CGSize newSize = CGSizeMake(newWidth, newHeight);
UIGraphicsBeginImageContext(newSize);
[image drawInRect:SetFrame(0, 0, newWidth, newHeight)];
UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
//图像压缩
NSData *newImageData = UIImageJPEGRepresentation(newImage, 0.5);
return [UIImage imageWithData:newImageData];
}