【发布时间】:2013-01-23 09:32:42
【问题描述】:
在上传图片之前我正在做以下操作。如果我在上传之前和上传之后检查图像的大小,它会加倍(即如果我上传了 2 MB 的图像,我可以在服务器上看到 4 MB 的图像)。
NSTimeInterval timeInterval = [assetDate timeIntervalSince1970];
ALAssetRepresentation *rep = [temp defaultRepresentation];
CGImageRef iref = [rep fullResolutionImage];
StrPath = [StrPath stringByAppendingFormat:@"%d.%@",(int)timeInterval,strImageType];
UIImage *image =[UIImage imageWithCGImage:iref scale:[rep scale] orientation:(UIImageOrientation)[rep orientation]];
NSData *dataObj = nil;
dataObj = UIImageJPEGRepresentation(image, 1.0);
NSString* StrFileData = [Base64 encode:dataObj];
NSString* strFileHash = [dataObj md5Test];
【问题讨论】:
-
我猜这取决于编码。
-
CGImageRef iref = [rep fullResolutionImage];这条线无论如何都会影响你认为@AKV
-
我不确定...您可以更改并检查 Base64 等,也可以尝试通过 UIImageJPEGRepresentation(image, 0.5) 压缩图像
-
不,我不需要压缩图像,我需要上传前后大小相同
-
取UIImageView和
imgeView.contentMode=UIViewContentModeScaleAspectFit;
标签: iphone objective-c xcode uiimage alassetslibrary