1.2.0 • Published 5 years ago
img2gcode v1.2.0
Image to GCode
Convert jpg, jpeg, png, gif to gcode with NodeJS.
- Generate GCode with absolute coordinates, finds a black pixel if you follow the trail.
- This version is faster previous versions.
- Find the shortest path to the next black pixel.

Installation
$ npm install img2gcodeQuick Start
Depending on the configuration between tool and image height generates better code.
var img2gcode = require("img2gcode");
img2gcode
.start({
// It is mm
toolDiameter: 2,
scaleAxes: 700,
deepStep: -1,
whiteZ: 0,
blackZ: -2,
safeZ: 2,
dirImg: __dirname + '/img-and-gcode/test.jpeg'
}).then((data) => {
console.log(data.config);
console.log(data.dirgcode);
});Options
toolDiameter(number) Tool diameter. default: 1sensitivity(number) Intensity sensitivity. 0 to 1. default: 0.95scaleAxes(number) Image height in mm. default: image.height equal mmdeepStep(number) Depth per pass. default: -1invest{ x: (boolean), y: (boolean) } default: {x: false, y: true}.dirImg(string) Image path, accepts JPEG JPG PNG GIF formats.whiteZ(number) White pixels. default: 0blackZ(number) Maximum depth (Black pixels).safeZ(number) Safe distance.info(string) Displays information. "none" | "console" | "emitter" default: nonefeedrate{ work: (number), idle: (number) } Only the corresponding line is added. default: ''laser{ commandPowerOn: (string), commandPowerOff: (string) } Is you set this options, Z command is will be ignore
Events
Only if Options.info it is "emitter"
logDisplays information.tickPercentage of black pixels processed. 0 (0%) to 1 (100%).errorDisplays error.completeEmits at the end with "then".
Method
thenThis function is called to finish saving the file GCode and receives an object: { config , dirgcode }
Examples
var img2gcode = require("img2gcode");
var ProgressBar = require("progress"); // npm install progress
var bar = new ProgressBar("Analyze: [:bar] :percent :etas", { total: 100 });
img2gcode
.start({
// It is mm
toolDiameter: 1,
scaleAxes: 700,
deepStep: -1,
feedrate: { work: 1200, idle: 3000 },
whiteZ: 0,
blackZ: -2,
safeZ: 1,
info: "emitter", // "none" or "console" or "emitter"
dirImg: __dirname + "/img-and-gcode/test.png",
})
.on("log", (str) => {
console.log(str);
})
.on("tick", (perc) => {
bar.update(perc);
})
.then((data) => {
console.log(data.dirgcode);
});Config for laser options
const options = {
// It is mm
toolDiameter: 3,
sensitivity: 0.9,
scaleAxes: 128,
feedrate: { work: 1200, idle: 3000 },
deepStep: -1,
laser: {
commandPowerOn: "M04",
commandPowerOff: "M05",
},
whiteZ: 0,
blackZ: -3,
safeZ: 1,
info: "emitter",
dirImg: path.normalize(__dirname + imgFile),
};License.
I hope someone else will serve (MIT).
Author: Marani Matias Ezequiel.
Buy Me A Coffee ☕️
1.2.0
5 years ago
1.1.2
7 years ago
1.1.1
7 years ago
1.1.0
7 years ago
1.0.6
7 years ago
1.0.5
8 years ago
1.0.4
8 years ago
1.0.3
8 years ago
1.0.2
9 years ago
1.0.1
9 years ago
1.0.0
9 years ago
0.1.13
9 years ago
0.1.10
9 years ago
0.1.9
9 years ago
0.1.8
9 years ago
0.1.7
9 years ago
0.1.6
9 years ago
0.1.4
9 years ago
0.1.3
9 years ago
0.1.2
10 years ago
0.1.1
10 years ago
0.1.0
10 years ago
0.0.13
10 years ago
0.0.12
10 years ago
0.0.11
10 years ago
0.0.10
10 years ago
0.0.9
10 years ago
0.0.8
10 years ago
0.0.7
10 years ago
0.0.6
10 years ago
0.0.5
10 years ago
0.0.4
10 years ago
0.0.3
10 years ago
0.0.1
10 years ago