ios上传图片-阳阳的

-(UIImage *)yasuoCameraImage:(UIImage *)image{
    int size = 204800;
    int current_size = 0;
    int actual_size = 0;
    NSData *imgData1 = UIImageJPEGRepresentation(image, 1.0);
    current_size = [imgData1 length];
    if (current_size > size) {
        actual_size = size/current_size;
        imgData1 = UIImageJPEGRepresentation(image, actual_size);
    }
    UIImage *theImage = [UIImage imageWithData:imgData1];
    return theImage; //返回压缩后的图片
}

imgData1 = UIImageJPEGRepresentation(image, actual_size);

猜你喜欢

转载自zhangmingwei.iteye.com/blog/1884974