我试图在照片库中保存照片,但它仍无法正常工作。好吧,我得到''错误:在控制台上捕获图像时出错,并且库中没有可见的图片。
这是我的代码:
document.getElementById("myBtn").addEventListener("click", function($scope, $cordovaCamera){
navigator.camera.getPicture(onGetPictureSuccess, onGetPictureFail, {
quality: 50,
destinationType: Camera.DestinationType.FILE_URI,
saveToPhotoAlbum: true
});
function onGetPictureSuccess(imageURI) {
console.log("success: " + imageURI);
}
function onGetPictureFail(message) {
console.log("error: " + message);
}
});
和我的配置:
<?xml version='1.0' encoding='utf-8'?>
<widget id="io.cordova.hellocordova" version="0.0.1" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
<name></name>
<description>
</description>
<author email="" href="">
</author>
<content src="index.html" />
<access origin="*" />
<allow-intent href="http://*/*" />
<allow-intent href="https://*/*" />
<allow-intent href="tel:*" />
<allow-intent href="sms:*" />
<allow-intent href="mailto:*" />
<allow-intent href="geo:*" />
<platform name="android">
<allow-intent href="market:*" />
</platform>
<platform name="ios">
<allow-intent href="itms:*" />
<allow-intent href="itms-apps:*" />
</platform>
<plugin name="cordova-plugin-email-composer" spec="~0.8.3" />
<plugin name="cordova-plugin-whitelist" spec="~1.2.2" />
<plugin name="cordova-plugin-x-socialsharing" spec="~5.1.1" />
<plugin name="cordova-plugin-console" spec="~1.0.3" />
<plugin name="cordova-plugin-device" spec="~1.1.2" />
<plugin name="cordova-plugin-compat" spec="~1.0.0" />
<plugin name="cordova-plugin-file" spec="~4.2.0" />
<plugin name="cordova-plugin-camera" spec="~2.2.0" />
</widget>
我需要将照片保存在Android和iOS图库都可以找到的位置。我不得不说,我对cordova应用程序的开发并不十分熟悉,这就是为什么我认为我错过了一些可以澄清这一点的小知识。
我偶然发现Android的内存问题行为会关闭并打开应用程序。我只能使用非常慢的模拟设备,这可能是个问题吗?
这个特定问题的Q / As大部分没有帮助我,也许我仍然错过了一些东西,但我正在研究这个问题几个小时,它让我有点疯狂..
问候
答案 0 :(得分:0)
<强> SaveImage 强> 此插件允许您将本地JPEG图像文件保存到iOS相机胶卷/照片库或Android图库。目前不支持其他图像mime类型。要保存到库/库的图像文件必须在设备上可用。
该插件基于其他几个现有插件中的代码:
Canvas2ImagePlugin(https://github.com/devgeeks/Canvas2ImagePlugin)by 汤米 - 卡洛斯威廉姆斯(https://github.com/devgeeks)ImgDownloader (https://github.com/Nomia/ImgDownloader)&#34; Nomia&#34; (https://github.com/Nomia) Max Lynch的cordova-camera-roll(https://github.com/driftyco/cordova-camera-roll) (https://github.com/mlynch)
感谢上述所有作者公开分享他们的代码。
cordova plugin add cordova-plugin-save-image