Canvas to PhotoLibrary [Phonegap]

前端 未结 3 495
鱼传尺愫
鱼传尺愫 2020-12-11 12:11

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

相关标签:
3条回答
  • 2020-12-11 12:49

    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.-

    0 讨论(0)
  • 2020-12-11 12:53

    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

    Example

    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
        );
    }
    
    0 讨论(0)
  • 2020-12-11 12:59

    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

    0 讨论(0)
提交回复
热议问题