如何调整从 nativescript-imagepicker 插件中选取的图像大小

Rad*_*ham 2 nativescript angular2-nativescript nativescript-angular

我已经在我的 Nativescript -Angular 代码中实现了 nativescript 图像选择器插件,但我试图弄清楚如何调整从 nativescript-imagepicker 中选取的图像的大小,该图像可以显示为圆圈中的帐户或个人资料图片

Man*_*noj 5

该图像将是ImageAssetselected的实例,您可以设置所需的选项,然后在ImageSource上调用 use fromAsset方法来调整图像大小。 widthheight

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
    });
Run Code Online (Sandbox Code Playgroud)