如何调整从 nativescript-imagepicker 插件中选取的图像的大小
how can I resize images picked from nativescript-imagepicker plugin
我已经在我的 Nativescript -Angular 代码中实现了 nativescript 图像选择器插件,但我想弄清楚如何调整从 nativescript-imagepicker 中选取的图像的大小,这些图像可以显示为圆形的帐户或个人资料图片
selected
图像将是 ImageAsset, you may set the options with desired width
and height
then call use fromAsset method on ImageSource 调整大小图像的实例。
context
.authorize()
.then(function() {
return context.present();
})
.then(function(selection) {
selection.forEach(function(selected) {
// Set values for width, height, keepAspectRatio (boolean)
selected.options = {width, height, keepAspectRatio };
imageSourceModule.fromAsset(selected)
.then((imageSource) => {
// imageSource is resized one
});
});
}).catch(function (e) {
// process error
});
我已经在我的 Nativescript -Angular 代码中实现了 nativescript 图像选择器插件,但我想弄清楚如何调整从 nativescript-imagepicker 中选取的图像的大小,这些图像可以显示为圆形的帐户或个人资料图片
selected
图像将是 ImageAsset, you may set the options with desired width
and height
then call use fromAsset method on ImageSource 调整大小图像的实例。
context
.authorize()
.then(function() {
return context.present();
})
.then(function(selection) {
selection.forEach(function(selected) {
// Set values for width, height, keepAspectRatio (boolean)
selected.options = {width, height, keepAspectRatio };
imageSourceModule.fromAsset(selected)
.then((imageSource) => {
// imageSource is resized one
});
});
}).catch(function (e) {
// process error
});