samt / barcode

barcode generation for nodejs
MIT License
69 stars 59 forks source link

Unhandled error and empty image #22

Open parth0595 opened 7 years ago

parth0595 commented 7 years ago
var barcode = require('barcode');
var path = require('path');
var code128 = barcode('code128', {
    data: "r1001-20160906-0001",
    width: 500,
    height: 100,
});
var outfile = path.join(__dirname, 'imgs', 'mm.png');
code128.saveImage(outfile, function (err) {

    if (err) throw err;
    console.log('File has been written!');

});

this is what I get.

throw er; // Unhandled 'error' event
      ^
Error: spawn gm ENOENT
    at exports._errnoException (util.js:1050:11)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:193:32)
    at onErrorNT (internal/child_process.js:367:16)
    at _combinedTickCallback (internal/process/next_tick.js:80:11)
    at process._tickCallback (internal/process/next_tick.js:104:9)
    at Module.runMain (module.js:607:11)
    at run (bootstrap_node.js:427:7)
    at startup (bootstrap_node.js:151:9)
    at bootstrap_node.js:542:3

It generates an empty image .

parth0595 commented 7 years ago

Found the solution. it works fine after installing graphics magic. @samt Is there any way we can use labels on top of the barcode generated?

ripu502 commented 5 years ago

for Linux (Ubuntu) user, you can solve this problem by running this in terminal sudo npm install --save gm sudo apt install graphicsmagick if the error continue : sudo npm install --save graphicsmagick sudo npm install --save imagemagick

Tanumay92 commented 5 years ago

Is there any way to solve in windows?? As I have already installed graphicsMagick.

ripu502 commented 5 years ago

Sorry, brother I have no experience with windows.

On Thu, 6 Jun, 2019, 2:00 AM Tanumay92, notifications@github.com wrote:

Is there any way to solve in windows?? As I have already installed graphicsMagick.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/samt/barcode/issues/22?email_source=notifications&email_token=AKD6IVLLBT4THPPCGWEGQC3PZAO57A5CNFSM4DRDPJJKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODXA5QJI#issuecomment-499243045, or mute the thread https://github.com/notifications/unsubscribe-auth/AKD6IVKX6R4D5UPHJYR3XK3PZAO57ANCNFSM4DRDPJJA .

Tanumay92 commented 5 years ago

Its solved... @ripu502

Hirurgo commented 5 years ago

@ripu502 For windows you need to install graphicsMagick application from official site http://www.graphicsmagick.org/ and restart your computer