Q:

ELECTRON: image file(.png) silent printing on Ubuntu

I'm making a Ubuntu based photo print program with Electron.
When I made on Windows,
I saved the image as PNG and called the windows built-in software(shimgvw.dll) with the code below.
await execPromise(`rundll32.exe c:\\windows\\System32\\shimgvw.dll,ImageView_PrintTo /pt "${process.cwd()}\\saved_image.png" "MY_PRINTER_MODEL_NAME"`);

What should I do in Ubuntu?
What I want to implement is to print the photos that have been finished composing at the user's choice by pressing a button.
When I do a search, I only get results for PDF files.
I wonder if there are any modules or commands.
Thank you!
P.S. Sorry for my bad English :(

A:

you can use Native bind printers on POSIX and Windows OS from Node.js, iojs and node-webkit.
npm install printer --target_arch=ia32
npm install printer --target_arch=x64

Say you are installing 1.4.5 electron. Please check the Releases for supported Electron versions
npm install printer --runtime=electron --target=1.4.5 --target_arch=x64
npm install printer --runtime=electron --target=1.4.5 --target_arch=ia32

For building after install
npm install -g node-gyp
npm install printer --msvs_version=2013  --build-from-source=node_printer

To print file:
// use: node printFile.js [filePath printerName]
var printer = require("../lib"),
    filename = process.argv[2] || __filename;

console.log('platform:', process.platform);
console.log('try to print file: ' + filename);

if( process.platform != 'win32') {
  printer.printFile({filename:filename,
    printer: process.env[3], // printer name, if missing then will print to default printer
    success:function(jobID){
      console.log("sent to printer with ID: "+jobID);
    },
    error:function(err){
      console.log(err);
    }
  });
} else {
  // not yet implemented, use printDirect and text
  var fs = require('fs');
  printer.printDirect({data:fs.readFileSync(filename),
    printer: process.env[3], // printer name, if missing then will print to default printer
    success:function(jobID){
      console.log("sent to printer with ID: "+jobID);
    },
    error:function(err){
      console.log(err);
    }
  });
}

