通过检查实际图像比例以减小图像尺寸,使用自定义尺寸调整UIImage。我已经尝试过这个UIImageJPEGRepresentation(Image,0.8);但问题是图像质量正在下降。任何帮助将非常感激。谢谢 最佳答案 将UIImage传递给下面的方法,该方法使用自定义高度/宽度调整图像大小,您还可以提供图像压缩值以减小图像大小,并在调整大小之前和之后检查图像大小。这是示例方法--(UIImage*)resizeImage:(UIImage*)image{NSIntegerimageActualSize=UIImageJPEGRe
我有这段代码可用于从服务器下载图像:-(void)loadDataWithOperation{//ConnectiontestNSURL*url=[NSURLURLWithString:@"http://myurl.com/testconnection.php"];NSError*error;NSString*connected=[NSStringstringWithContentsOfURL:urlencoding:NSASCIIStringEncodingerror:&error];//IfthestringConnectedhasNOTmangedtoinitialiseitse
如何在不影响质量的情况下以编程方式缩小图像。捕获图像后,我想在不改变objective-c质量的情况下减小该图像的大小。 最佳答案 这是我用来压缩图片的代码代码:-(UIImage*)compressImage:(UIImage*)image{NSData*imgData=UIImageJPEGRepresentation(image,1);//1itrepresentsthequalityoftheimage.NSLog(@"SizeofImage(bytes):%ld",(unsignedlong)[imgDatalength]
我正在使用以下代码进行图像压缩。代码压缩大于2MB的图像文件。但此代码需要时间,而且图像质量保持纯净。publicstaticStringcompressImage(StringimagePath,Contextcontext){StringresizeImagePath=null;StringfilePath=imagePath;CustomLogHandler.printDebug(TAG,"resizeImagePath:"+imagePath);BitmapscaledBitmap=null;intimageScal=1;//Filesizegreaterthen2mbDeci
我正在使用以下代码进行图像压缩。代码压缩大于2MB的图像文件。但此代码需要时间,而且图像质量保持纯净。publicstaticStringcompressImage(StringimagePath,Contextcontext){StringresizeImagePath=null;StringfilePath=imagePath;CustomLogHandler.printDebug(TAG,"resizeImagePath:"+imagePath);BitmapscaledBitmap=null;intimageScal=1;//Filesizegreaterthen2mbDeci