{"id":18761214,"url":"https://github.com/maranimatias/img2gcode","last_synced_at":"2025-04-13T03:31:27.457Z","repository":{"id":11005406,"uuid":"67902388","full_name":"MaraniMatias/img2gcode","owner":"MaraniMatias","description":"convert jpg, png,gif to gcode  with nodejs and jimp","archived":false,"fork":false,"pushed_at":"2022-04-10T07:01:38.000Z","size":23212,"stargazers_count":41,"open_issues_count":2,"forks_count":8,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-12T21:16:37.336Z","etag":null,"topics":["gcode","gif","jpeg","nodejs","npm-package","png"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/MaraniMatias.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-09-11T00:57:52.000Z","updated_at":"2025-02-21T16:15:18.000Z","dependencies_parsed_at":"2022-08-07T06:01:01.739Z","dependency_job_id":null,"html_url":"https://github.com/MaraniMatias/img2gcode","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MaraniMatias%2Fimg2gcode","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MaraniMatias%2Fimg2gcode/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MaraniMatias%2Fimg2gcode/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MaraniMatias%2Fimg2gcode/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MaraniMatias","download_url":"https://codeload.github.com/MaraniMatias/img2gcode/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248659645,"owners_count":21141152,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["gcode","gif","jpeg","nodejs","npm-package","png"],"created_at":"2024-11-07T18:15:21.864Z","updated_at":"2025-04-13T03:31:27.043Z","avatar_url":"https://github.com/MaraniMatias.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Image to GCode\n\nConvert jpg, jpeg, png, gif to gcode with NodeJS.\n\n- Generate GCode with absolute coordinates, finds a black pixel if you follow the trail.\n- This version is faster previous versions.\n- Find the shortest path to the next black pixel.\n\n![img2gcode with CNC-ino](https://github.com/MaraniMatias/img2gcode/blob/master/ej-img2gcode.png)\n\n### Installation\n\n```bash\n$ npm install img2gcode\n```\n\n## Quick Start\n\nDepending on the configuration between tool and image height generates better code.\n\n```Javascript\nvar img2gcode = require(\"img2gcode\");\n\nimg2gcode\n  .start({\n    // It is mm\n    toolDiameter: 2,\n    scaleAxes: 700,\n    deepStep: -1,\n    whiteZ: 0,\n    blackZ: -2,\n    safeZ: 2,\n    dirImg: __dirname + '/img-and-gcode/test.jpeg'\n  }).then((data) =\u003e {\n    console.log(data.config);\n    console.log(data.dirgcode);\n  });\n```\n\n### Options\n\n- `toolDiameter` (number) Tool diameter. **default:** 1\n- `sensitivity` (number) Intensity sensitivity. 0 to 1. **default:** 0.95\n- `scaleAxes` (number) Image height in mm. **default:** image.height equal mm\n- `deepStep` (number) Depth per pass. **default:** -1\n- `invest` { x: (boolean), y: (boolean) } **default:** {x: false, y: true}.\n- `dirImg` (string) Image path, accepts JPEG JPG PNG GIF formats.\n- `whiteZ` (number) White pixels. **default:** 0\n- `blackZ` (number) Maximum depth (Black pixels).\n- `safeZ` (number) Safe distance.\n- `info` (string) Displays information. [\"none\" | \"console\" | \"emitter\"] **default:** none\n- `feedrate` { work: (number), idle: (number) } Only the corresponding line is added. **default:** ''\n- `laser` { commandPowerOn: (string), commandPowerOff: (string) } Is you set this options, Z command is will be ignore\n\n### Events\n\nOnly if Options.info it is \"emitter\"\n\n- `log` Displays information.\n- `tick` Percentage of black pixels processed. 0 (0%) to 1 (100%).\n- `error` Displays error.\n- `complete` Emits at the end with \"then\".\n\n### Method\n\n- `then` This function is called to finish saving the file GCode and receives an object: { config , dirgcode }\n\n### Examples\n\n```javascript\nvar img2gcode = require(\"img2gcode\");\nvar ProgressBar = require(\"progress\"); // npm install progress\nvar bar = new ProgressBar(\"Analyze: [:bar] :percent :etas\", { total: 100 });\n\nimg2gcode\n  .start({\n    // It is mm\n    toolDiameter: 1,\n    scaleAxes: 700,\n    deepStep: -1,\n    feedrate: { work: 1200, idle: 3000 },\n    whiteZ: 0,\n    blackZ: -2,\n    safeZ: 1,\n    info: \"emitter\", // \"none\" or \"console\" or \"emitter\"\n    dirImg: __dirname + \"/img-and-gcode/test.png\",\n  })\n  .on(\"log\", (str) =\u003e {\n    console.log(str);\n  })\n  .on(\"tick\", (perc) =\u003e {\n    bar.update(perc);\n  })\n  .then((data) =\u003e {\n    console.log(data.dirgcode);\n  });\n```\n\n**Config for laser options**\n\n```javascript\nconst options = {\n  // It is mm\n  toolDiameter: 3,\n  sensitivity: 0.9,\n  scaleAxes: 128,\n  feedrate: { work: 1200, idle: 3000 },\n  deepStep: -1,\n  laser: {\n    commandPowerOn: \"M04\",\n    commandPowerOff: \"M05\",\n  },\n  whiteZ: 0,\n  blackZ: -3,\n  safeZ: 1,\n  info: \"emitter\",\n  dirImg: path.normalize(__dirname + imgFile),\n};\n```\n\n### License.\n\nI hope someone else will serve ([MIT](http://opensource.org/licenses/mit-license.php)).\n\nAuthor: Marani Matias Ezequiel.\n\n---\n\n### Buy Me A Coffee ☕️\n\n\u003cp\u003e\u003cimg src=\"https://simpleicons.org/icons/bitcoin.svg\" height=\"12\" /\u003e \u003cb\u003eBitcoin\u003c/b\u003e\u003c/p\u003e\n\u003cp\u003e\n  1N7dWTf1JcvYG2QwviyjwYMw6qY5agx9Qm\n\u003c/p\u003e\n\u003cp\u003e\u003cimg src=\"https://simpleicons.org/icons/ethereum.svg\" height=\"12\" /\u003e \u003cb\u003eEthereum\u003c/b\u003e\u003c/p\u003e\n  0x555d4510b4b3db02d81be5114919e7c8c4156b77\n\u003cp\u003e\n\u003c/p\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaranimatias%2Fimg2gcode","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmaranimatias%2Fimg2gcode","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaranimatias%2Fimg2gcode/lists"}