0
我正在使用Ionic 2和cordova-plugin-crop裁剪圖像。裁剪時的cordova-plugin-crop錯誤404
如果我拍照(pictureSourceType === navigator.camera.PictureSourceType.CAMERA
),裁剪工作正常,但如果我從一個文件夾(pictureSourceType === navigator.camera.PictureSourceType.SAVEDPHOTOALBUM
)中選擇一個圖片,並嘗試裁剪,我得到:
錯誤對種植404
這裏是我的代碼:
takeThePhoto(pictureSourceType: any) {
let options = {
sourceType: pictureSourceType,
destinationType: Camera.DestinationType.FILE_URI,
quality: 50,
targetWidth: 720,
correctOrientation: true,
encodingType: Camera.EncodingType.JPEG
}
if (pictureSourceType === navigator.camera.PictureSourceType.SAVEDPHOTOALBUM) {
options.correctOrientation = false;
}
Camera.getPicture(options).then((imageURI) => {
window['plugins'].crop.promise(imageURI, {
quality: 75
}).then(newPath => {
alert('newPath = ' + newPath);
return this.toBase64(newPath).then((base64Img) => {
this.base64Image = base64Img;
}).catch((error) => {
console.error("ERROR -> " + JSON.stringify(error));
alert("ERROR: " + JSON.stringify(error));
});
},
error => {
console.error("CROP ERROR -> " + JSON.stringify(error));
alert("CROP ERROR: " + JSON.stringify(error));
}
).catch((error) => {
console.error("ERROR imageURI -> " + JSON.stringify(error));
alert("ERROR imageURI: " + JSON.stringify(error));
});
},
error => {
// console.error("CAMERA ERROR -> " + JSON.stringify(error));
// alert("CAMERA ERROR: " + JSON.stringify(error));
}
).catch((error) => {
console.error("ERROR getPicture -> " + JSON.stringify(error));
alert("ERROR getPicture: " + JSON.stringify(error));
});
}
任何幫助表示讚賞。
謝謝你,我想你的建議。我認爲代碼有點整潔,但在嘗試裁剪選定的文件時仍然遇到相同的404問題。 – Richard
對不起,我的錯誤,跟隨您發送的鏈接,現在工作。感謝您的幫助。 – Richard