曝光相机拍摄图片异步图像操纵器



>我有一个这样的片段

takePicture = async function() {
if (this.camera) {
this.camera
.takePictureAsync()
.then(data => {
FileSystem.moveAsync({
from: data.uri,
to: `${FileSystem.documentDirectory}photos/Photo_${
this.state.photoId
}.jpg`
}).then(() => {
this.setState({
photoId: this.state.photoId + 1
});
Vibration.vibrate();
});
});
}
};

现在我的问题是我不知道如何将图像操纵器插入到这个函数中。我的目的是在takePictureAsync((之后,照片的大小将调整为108x192,然后这张照片将被移动到documentDirectory。非常感谢

我已经找到了解决方案,这是代码

takePicture = async function() {
if (this.camera) {
let photo = await this.camera.takePictureAsync();
let resizedPhoto = await ImageManipulator.manipulate(
photo.uri,
[{ resize: { width: 108, height: 192 } }],
{ compress: 0, format: "jpg", base64: false }
);
FileSystem.moveAsync({
from: resizedPhoto.uri,
to: `${FileSystem.documentDirectory}photos/Photo_${
this.state.photoId
}.jpg`
});
this.setState({ photoId: this.state.photoId + 1 });
Vibration.vibrate();            
}
};

最新更新