方法一:
CGSize newSize=CGSizeMake(100, 100);
UIGraphicsBeginImageContext(newSize); //开启图形上下文
[image drawInRect:CGRectMake(0,0,newSize.width,newSize.height)]; 图片从新绘制
UIImage* newImage = UIGraphicsGetImageFromCurrentImageContext();//从图形上下文获取新的图片
UIGraphicsEndImageContext(); //关闭图形上下文
/////////////
方法二:
UIImage *image = info[UIImagePickerControllerEditedImage];
NSData *imageData = UIImageJPEGRepresentation(image, 0.2);//对图像做了压缩,0.2是失真度
UIGraphicsBeginImageContextWithOptions(image.size,NO,0.2);//参数:上下文区域大小,是否透明,缩放率
[image drawInRect:CGRectMake(0,0,image.size.width,image.size.height)];
UIImage*
newImage = UIGraphicsGetImageFromCurrentImageContext();//从图形上下文获取新的图片
UIGraphicsEndImageContext();