首页 > 代码库 > 图片压缩

图片压缩

+(UIImage *)maxSize_is64:(BOOL)is64 or_640:(BOOL)is640 image:(UIImage *)_image
{
    if (is64 == YES) {
        float temp = _image.size.height > _image.size.width ? _image.size.height:_image.size.width;
        float a = temp/320;
        CGSize size = CGSizeMake(_image.size.width/a, _image.size.height/a);
        UIImage *newImage = [self  imageWithImage:_image scaledToSize:size];
        UIImage *__newImage = [self fixOrientation:newImage];
        return __newImage;
    }
    if (is640 == YES) {
        float temp = _image.size.height > _image.size.width ? _image.size.height:_image.size.width;
        float a = temp/640;
        CGSize size = CGSizeMake(_image.size.width/a, _image.size.height/a);
        UIImage *newImage = [self  imageWithImage:_image scaledToSize:size];
        UIImage *__newImage = [self fixOrientation:newImage];
        return __newImage;
    }
    return nil;

}

图片压缩