我想减小相机 API 拍摄的图像的大小,但质量降低并不好。最好的办法是降低分辨率,但我不想为所有图像使用目标宽度和高度。
例如,我希望图像宽度为 1280 并且图像高度按比例自动更改,但在 API 中我应该使用精确的宽度和高度。
如何通过图像比例更改高度动态???
现在,我使用以下代码:
this.camera.getPicture({
quality: 60,
destinationType: this.camera.DestinationType.FILE_URI,
sourceType: sourceType,
mediaType: this.camera.MediaType.PICTURE,
targetWidth: 1280,
targetHeight: 1280,
encodingType: this.camera.EncodingType.JPEG,
saveToPhotoAlbum: (source === PictureSource.CAMERA),
allowEdit: true
})
Run Code Online (Sandbox Code Playgroud)