保存PNG或JPG图像照片在iOS的PhoneGap的经 [英] Saving a PNG or JPG image to Photos in iOS via PhoneGap
问题描述
我是新来的PhoneGap,并想知道如何在应用程序内的图像保存到照片中的iOS。
I am new to PhoneGap and would like to know how to save an in-App image to Photos in iOS.
虽然我能够用
navigator.camera.getPicture
与选项
quality:50, destinationType:Camera.DestinationType.DATA_URL,saveToPhotoAlbum: true
要保存相机照片拍摄的照片,我现在试图找出如何在应用程序内的图像保存到图片。
to save a picture taken with the camera to Photos, I am now trying to find out how to save an in-App image to Photos.
考虑以下PhoneGap的 - 那里的元素myPhoto持有的imageData科尔多瓦页面,如数据:图像/ JPEG; BASE64,...
Consider the following PhoneGap - Cordova page where the element myPhoto holds imagedata such as "data:image/jpeg;base64,"...
<html>
<head>
<title>Save Image</title>
<script type="text/javascript" charset="utf-8" src="cordova-2.1.0.js"></script>
<script type="text/javascript" charset="utf-8">
function savePicture(){
//this is where the magic would happen
//how can I save myPhoto to Photos?
//output imageData to a jpg or png file which would show up in Photos?
}
</script>
</head>
<body>
<button onclick="savePicture();">Save Photo</button> <br>
<input type="hidden" name="myPhoto" id="myPhoto" value="">
</body>
</html>
问:
什么都要savePicture()通过做PhoneGap的保存从myPhoto到照片中为imageData iOS中?
What should savePicture() do to save the imagedata from myPhoto to Photos in iOS via Phonegap?
推荐答案
我最近遇到下面的PhoneGap插件来为iOS中保存画布图像照片:
https://github.com/devgeeks/Canvas2ImagePlugin
I recently came across the following Phonegap plugin for saving Canvas images to Photos in iOS: https://github.com/devgeeks/Canvas2ImagePlugin
请按照自述的说明 导入插件,然后你可以使用它通过以下方式:
Follow the readme instructions for importing the plugin and then you can use it the following way:
<html>
<head>
<title>Save Image</title>
<script type="text/javascript" charset="utf-8" src="cordova-2.1.0.js"></script>
<script type="text/javascript" charset="utf-8" src="../Canvas2Image/Canvas2ImagePlugin.js"></script>
<script type="text/javascript" charset="utf-8">
var canvas2ImagePlugin; //devgeeks plugin for saving canvas images to photo gallery
function onDeviceReady() {
canvas2ImagePlugin = window.plugins.canvas2ImagePlugin;
}
function savePicture(){
canvas2ImagePlugin.saveImageDataToLibrary(function(msg){console.log(msg);},function(err){console.log(err);},'mycanvas');
}
</script>
</head>
<body>
<canvas id="myCanvas" width="500px" height="300px"> <strong>[Your browser can not show this example.]</strong> </canvas>
<button onclick="savePicture();">Save Photo</button> <br>
</body>
</html>
这篇关于保存PNG或JPG图像照片在iOS的PhoneGap的经的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!