Мне нужно обрезать изображение. Если я просто сохраняю изображение на сервер, все в порядке, но если я использую 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
);
});
});
});
}