taiyang2014

iOS 图片压缩

+ (UIImage *)scaleFromImage:(UIImage *)image {
    CGSize newSize = CGSizeMake(366, 366);   //目标图片的大小
    UIGraphicsBeginImageContext(newSize);
    [image drawInRect:CGRectMake(0,0,newSize.width,newSize.height)];
    UIImage* newImage = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
   
    NSData *data1 = UIImagePNGRepresentation(newImage);
        CGFloat dataSize1 = data1.length/1024;
        NSLog(@"###########%.2f",dataSize1);
    return newImage;
}

posted on 2016-09-26 17:19  taiyang2014  阅读(273)  评论(1编辑  收藏  举报

导航