Well, I have dealed quite well with several images onto canvas and now the questions lays in exporting to Photo library on iOS throught Phonegap. I\'ve read a lot relates to
Well, the solutions consists in re-write the khamer's plugin SaveImage from: https://github.com/khamer/phonegap-plugins-official/tree/master/iPhone/SaveImage
Greetings, DGM.-
I read this and thought "how hard could it be?".
So I hacked one up real quick.
Let me know if it works OK.
https://github.com/devgeeks/Canvas2ImagePlugin
In your html:
<canvas id="myCanvas" width="165px" height="145px"></canvas>
then in onDeviceReady
:
function onDeviceReady()
{
var canvas2ImagePlugin = window.plugins.canvas2ImagePlugin;
}
then in the function to save your canvas:
// where myCanvasId == 'myCanvas' (the id of the canvas above)
function mySavingFunction(myCanvasId) {
canvas2ImagePlugin.saveImageDataToLibrary(
function(msg){
console.log(msg);
},
function(err){
console.log(err);
},
myCanvasId
);
}
After few years, the plugin can do more and support IOS previous issued.
Now u can choose either to save as jpg/png
, set quality
and set outputfolder
function onDeviceReady()
{
window.canvas2ImagePlugin.saveImageDataToLibrary(
function(msg){
console.log(msg); //msg is the filename path (for android and iOS)
},
function(err){
console.log(err);
},
document.getElementById('myCanvas'),
'.jpg', // save as jpg
80, // image quality
'cunvaspluginfolder' //folder name
);
}
Credit to wbt11a because make this plugin more configurable from original author.
Please download the new plugin here Github source