【发布时间】:2020-06-14 09:12:54
【问题描述】:
我需要裁剪我的图像。如果我只是保存图像 ti 服务器没关系,但如果我使用 imagecropper 我没有任何图像源。 ImageCropper 返回args.image = {android: {}}。
我使用 nativescript-imagecropper 插件。
这是我的裁剪方法:
public onTakePicture(): void {
const options = { lockSquare: true };
const androidOptions = <OptionsAndroid>{
isFreeStyleCropEnabled: true,
statusBarColor: 'black',
setAspectRatioOptions: {
defaultIndex: 0,
aspectRatios: [
{
aspectRatioTitle: '1:1',
aspectRatioX: 1,
aspectRatioY: 1
},
{
aspectRatioTitle: '16:9',
aspectRatioX: 16,
aspectRatioY: 9
},
{
aspectRatioTitle: '18:9',
aspectRatioX: 18,
aspectRatioY: 9
}
]
}
};
requestPermissions().then(() => {
takePicture({ width: 300, height: 300, keepAspectRatio: true }).then((image) => {
ImageSource.fromAsset(image).then((source) => {
setTimeout(
() => {
this.imageCropper
.show(source, options, androidOptions)
.then((args) => {
if (args.image !== null) {
this.imageUrl = args.image;
}
})
.catch(function (e) {
console.dir(e);
});
},
isAndroid ? 0 : 1000
);
});
});
});
}
【问题讨论】:
标签: angular nativescript tns