关于IOS使用Cordova camera 无法压缩图片

问题描述:

使用Cordova navigator.camera.getPicture拍照插件,结合文件上传实现拍照上传,将quality设置为30,在做测试时发现IOS上传的图片明显比android的图片大,分析发现IOS上传的文件为未压缩图片文件。

解决方法:

设置targetWidth和targetHeight来实现对图片的控制。

navigator.camera.getPicture(function(fileFullPath){
			$("#imgSrc").attr("src", fileFullPath);
			onDeviceReady(fileFullPath);
    	}, function(errMsg){
    		alert(errMsg);
    	},{
    	    quality: 50,
    	    destinationType: Camera.DestinationType.FILE_URI,
    	    targetWidth: 300,	// 以像素为单位,图片比例保持不变
    	    targetHeight: 300	// 以像素为单位,图片比例保持不变
    	});


猜你喜欢

转载自blog.csdn.net/u014505277/article/details/78055143