img2gcode

img2gcode: A tool that converts images to plotter G-code in one step. Drag an image file in and .svg and .gcode files are generated in the same folder. Intended for scenarios that need to convert photos/images to SVG vector paths and then generate G-code suitable for plotters/pen plotters. Trigger phrases include “image to gcode”, “generate gcode from image”, and related terms.

Installation

Review the source and dependencies with a prompt.

Install with an AI assistant

Copy the prompt so your assistant can review the pinned revision and dependencies first.

View promptHide prompt
Check whether SkillPI Skill Finder is installed for your current agent. If it is missing, install and enable it using the official instructions at https://github.com/Findskills/skillpi. Then use Skill Finder to locate and install "img2gcode" from this exact SkillPI detail page: https://skillpi.com/skills/deepskill-9296d5fa81d61084be22158840a1f4371bb428b2fb303be4c44b807e868f8b61. Verify the upstream source and version against https://skillhub.cn/skills/user_baad803c/img-to-gcode before installing. If they do not match, stop and report the mismatch. Report the installed path and source version.

Download permission for this version is unverified or restricted.

Source and setup

skillhub.cn

Setup guidance pending

See the original source for supported tools, dependencies, and permissions.

Installation test pending

img2gcode: A tool that converts images to plotter G-code in one step. Drag an image file in and .svg and .gcode files are generated in the same folder. Intended for scenarios that need to convert photos/images to SVG vector paths and then generate G-code suitable for plotters/pen plotters. Trigger phrases include “image to gcode”, “generate gcode from image”, and related terms.

0 Downloads

Introduction source: third_party · user_baad803c · 1.0.0 Reference

SkillPi interpretation

Tasks
Convert raster images to pen-plotter G-code via SVG vectorization. Outputs `.svg` and `.gcode` in the current working directory alongside the input image.
Audience
Not specified in the source documentation.
Inputs and outputs
Not specified in the source documentation.
Software, accounts and paid services
Not specified in the source documentation.
Limits and differences
Not specified in the source documentation.
Testing
Not tested

Browse files

A verified file list is not available on Skillπ yet.

Browse files at the source ↗

Original SKILL.md

Open original ↗
Frontmatter
name: img2gcode
description: "Convert images to pen-plotter G-code in one step. Drop an image file, get .svg and .gcode in the same folder. Use when the user wants to convert a photo/image into SVG vector paths, then generate G-code for a pen plotter / writing machine. Triggers: 图片转gcode, img2gcode, 照片转写字机, image to gcode, generate gcode from image, 把这张图转成gcode."

img2gcode - Image to SVG to G-code Pipeline

Convert raster images to pen-plotter G-code via SVG vectorization. Outputs .svg and .gcode in the current working directory alongside the input image.

Workflow Overview

用户拖入图片 → save_image.py (保存到本地) → run.py (转 SVG + G-code)

Step 1: 用户上传图片

用户在 WorkBuddy 中拖入一张图片,引用格式为 @image:<文件名> 或 @文件:<文件名>。

Step 2: 保存图片到临时文件夹

通过 save_image.py 将图片复制到当前工作目录,输出格式为 _input_<hash12>.<ext>:

python "{SKILL_DIR}/scripts/save_image.py" "<图片路径>"

脚本会返回保存后的文件路径(例如 _input_a1b2c3d4e5f6.png),供下一步使用。

Step 3: 运行转换管线

将上一步输出的路径作为参数传入 run.py:

python "{SKILL_DIR}/scripts/run.py" "_input_a1b2c3d4e5f6.png"

输出文件:

  • _input_a1b2c3d4e5f6.svg
  • _input_a1b2c3d4e5f6.gcode

Step 4: 自动打开文件夹

run.py 运行完毕后会自动打开输出文件夹(调用 Windows Explorer),用户可直接查看 .svg 和 .gcode 文件。

Step 5: 在线查看 G-code

将生成的 .gcode 文件内容粘贴到 NCViewer 即可在线预览路径轨迹。

完整命令行示例(两步连用)

python "{SKILL_DIR}/scripts/save_image.py" "C:/Users/xxx/Desktop/photo.jpg"
python "{SKILL_DIR}/scripts/run.py" "_input_a1b2c3d4e5f6.jpg"

或者图片已在磁盘上,直接运行:

python "{SKILL_DIR}/scripts/run.py" "C:/Users/xxx/Desktop/photo.jpg"

Scripts

scripts/run.py

Main entry point. Accepts an image path, runs the full pipeline, outputs .svg and .gcode in the same directory.

scripts/img2svg.py

Image preprocessing and potrace invocation:

  • Gaussian blur + CLAHE contrast enhancement
  • Adaptive binary thresholding
  • Morphological close/open to clean noise
  • potrace with tuned parameters for smooth curve output

scripts/svg2gcode.py

SVG path to G-code conversion. Configurable pen-plotter parameters:

  • Scale, offset, Y-flip, pen Z heights, feed rates, curve sampling

Dependencies

Pen Plotter Parameters

Default values (edit in scripts/svg2gcode.py): | Parameter | Default | Description | |-----------|---------|-------------| | SCALE | 0.0018 | pixel → mm scale factor | | OFFSET_X | 10.0 | X origin offset (mm) | | OFFSET_Y | 20.0 | Y origin offset (mm) | | PEN_UP_Z | 3.0 | Pen lift height (mm) | | PEN_DOWN_Z | -0.5 | Pen drawing depth (mm) | | FEED_MOVE | 3000 | Travel speed (mm/min) | | FEED_DRAW | 1500 | Drawing speed (mm/min) | | SAMPLE_COUNT | 18 | Bezier sampling points per curve |

Current listing version

1.0.0

Verify the source revision ↗

Safety and assessment details

Quality assessment

Out of 100 · Assessment report from SkillPi LAB.

Scenario Value92/100

Highlights

  • 提供端到端图像转 G-code 解决方案,满足绘图仪/写字机用户需求
  • 流程清晰,输出文件可直接用于实际设备
Trigger Precision95/100

Highlights

  • 触发词覆盖中英文常见表达,边界清晰无歧义
Structure and Standards90/100

Highlights

  • 步骤划分清晰,含完整命令行示例和参数说明
Execution Reliability70/100

Areas to improve

  • potrace 依赖需手动安装 Reported severity: Major

    potrace 需用户手动下载解压,未集成自动化安装或错误处理

    Recommendation: 建议将 potrace 二进制文件打包进 Skill,或在脚本中自动检测并引导安装

Evidence Verifiability (mean of the first four)87/100

The arithmetic mean of the first four original scores, rounded to a whole number.

Static text checks

100 / 100 · skillpi-20261123-no-r3-v1

No current rules matched the text.

This score reflects rule matches in the text and is provided for reference before use. It excludes attachments and runtime behavior.

Permissions and checks before use

Automatically summarized from this main document. Matches may be examples or defensive advice; they are not actual permission declarations. Attachments, external dependencies and runtime behavior are not covered.

These common operations were not identified in the main document. This does not mean no permissions or risks exist.

Domains or addresses referenced in the document

These addresses may be documentation links or examples, not an approved network allowlist. Verify actual destinations and outgoing data before use.

  • ncviewer.com
  • potrace.sourceforge.net

These notices grant no permissions. Your host tool must still confirm file changes, secrets, external transfers or costs as needed.

Security rating and access scope

risk · Static evidence review; not a runtime safety guarantee.

Not specified in the source documentation.

Before use, confirm and authorize actual file access, external services and network destinations in your host. This review grants no runtime permissions.