gpt4 book ai didi

ionic-framework - 如何在没有质量降低和目标宽度和高度的情况下在 Ionic 3 中调整图像大小?

转载 作者:行者123 更新时间:2023-12-05 00:49:03 25 4
gpt4 key购买 nike

我想减小相机 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
})

最佳答案

使用 Cordova 插件中的这些选项:

targetWidth:缩放图像的宽度(以像素为单位)。必须与 targetHeight 一起使用。纵横比保持不变。 (数量)

targetHeight:缩放图像的高度(以像素为单位)。必须与 targetWidth 一起使用。纵横比保持不变。 (数量)

这样

var options = {
quality: 100,
sourceType: sourceType,
saveToPhotoAlbum: false,
correctOrientation: true,
destinationType: this.camera.DestinationType.DATA_URL,
targetWidth: 400,
targetHeight: 400,
};

// Get the data of an image
this.camera.getPicture(options).then((imageData) => {
//use the imageData as required.
}, (err) => {

}).catch((error) => {

})

关于ionic-framework - 如何在没有质量降低和目标宽度和高度的情况下在 Ionic 3 中调整图像大小?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46150790/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com