NWjs - Write File in ".png"

  • I need to save as PNG-file my CanvasSnapshot.

    "Brower.InvodeDownload" can do it, but "NWjs.WriteFile" creates the unreadable file in PNG-format.

    Is there any way to do it?

  • InvokeDownload works perfect and can save *png.

    Why would you need to use anything else?

  • To cut a long story short I have found the solution by myself.

    We should use "tokenat(CanvasSnapshot,1,",")" instead of just "CansavSnapshot".

    Also we should find "writefile" function in "c2runtime.js", go 5 steps down and change "UTF8" with "Base64"

  • InvokeDownload works perfect and can save *png.

    Why would you need to use anything else?

    Because I am creating a program like "Spriter" and I do not want user to click LMB every time my program saves the image.

  • Well if your program will be more like thing we had in Construct Classic I would be more than glad to purchase it! Best of luck.

  • Well if your program will be more like thing we had in Construct Classic I would be more than glad to purchase it! Best of luck.

    Thank you. I will try my best.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • To cut a long story short I have found the solution by myself.

    We should use "tokenat(CanvasSnapshot,1,",")" instead of just "CansavSnapshot".

    Also we should find "writefile" function in "c2runtime.js", go 5 steps down and change "UTF8" with "Base64"

    Hi,

    Do you happen to have an example available? i am trying to do the same thing. I would like to download an image without giving the user a pop up.

    Thanks,

  • Nw.js write image file

    For screenshot:

    Browser.ExecJS("var fs = require('fs');fs['writeFileSync']('" &replace(NodeWebkit.UserFolder & "screenshot" & ".png","\","\\")& "','" &CanvasSnapshot& "'.split(',')[1], {'encoding': 'base64'});")
    [/code:1h44l4vf]
    
Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)