Close
0%
0%

imgcode - simple image etching gcode generator

imgcode is image etching gcode generator aimed at laser CNC machines

Similar projects worth following
imgcode is image etching gcode generator aimed at laser CNC machines. I made it to support grbl controlled laser, but it should work on every CNC machine (but may need some changes in code)

Please consider some donation for the time and effort I used to develop his project. I included PayPal link in the links area (under gallery and team on the left of this page

Code and compiled exec are hosted on GitHub: github.com/vidmo91/imgcode

gcode visualisation made with: ncviewer.com

imgcode allows to convert quite any image file to gcode.

I made simple GUI for imgcode. run it by double-clicking imgcode_gui.ede in dist folder or with command : 

python .\imgcode_gui.py

It requires imgcode_cli4gui script or exec and icon.ico file to run, so download whole repo for script usage or at least dist folder for exec usage. Parameters are the same as in CLI version, they're specified below.

The CLI version of imgcode  have to be executed as python script or precomipiled exec file with input parameters:

.\python.exe image_path output_file_path x_offset_mm y_offset_mm output_image_horizontal_size_mm pixel_size_mm feedrate max_laser_power number_of_colours
.\python.exe lena.png test.nc 0 0 10 0.2 100 255 5
.\python.exe "C:\Documents\laser files\lena.png" "C:\laser files\out files\output_gcode.nc" 0 0 10 0.2 220 1000 5 
python .\imgcode.py image_path output_file_path x_offset_mm y_offset_mm output_image_horizontal_size_mm pixel_size_mm feedrate max_laser_power number_of_colours
python .\imgcode.py lena.png test.nc 0 0 10 0.2 100 255 5
python .\imgcode.py "C:\Documents\laser files\lena.png" "C:\laser files\out files\output_gcode.nc" 0 0 10 0.2 220 1000 5

Exec I made is in dist folder and is precompiled for Windows x64. I tested it on Win10 and Win7. It is much slower than python script, but it requires minimal effort .

Required input parameters:

image_path - path to image file you want to process
output_file_path - gcode file path
x_offset_mm - parameter offsetting lower left corner of image from machine's origin
y_offset_mm - same as x offset
output_image_horizontal_size_mm - horizontal size of etched image - file will be scaled to that value
pixel_size_mm - step between pixels
feedrate - speed of laser head in mm/min
max_laser_power - maximum laser power value
number_of_colours - number of colour in output picture 2 is minimum, 255 maximum.

imgcode algorithm:

read image,
convert image to grayscale,
resize image - scale is based on horizontal size and pixel size,
quantisation of color values - to the number of colors provided,
gcode generation - image size is calculated from image array size and pixel size value, laser power is taken from image pixel value.

imgcode was coded in python 3.7.2. All required python modules with version I used are listed in requirements file. I made install_requirements batch file installing all needed modules for simple Windows "installation".

Compiling to executable file can be done with pyinstaller module. First install it with command (it installs the same version I have):

pip install PyInstaller==3.4 --force-reinstall  

Then compile imgcode with command (compile as one-file console application with icon.ico icon):

pyinstaller --onefile .\imgcode.py -c -i icon.ico

It should work on any PC with the same system type (Windows, Linux, etc.) and the same CPU architecture as PC it was compiled on.  Before compiling again delete build folder and imgcode.spec file, otherwise it won't recompile.

  • first fully working version and GUI

    vidmo04/08/2019 at 16:36 0 comments

    Today I fixed last bugs I knew and added last functionality I wanted to implement.:

    • offsets are working now
    • toolpaths are in places they should be.

    Also today I made simple GUI. It has buttons calling file selection windows, input fields for numerical parameters (default values can be changed in code, for now, maybe in ini file some day...), output text field for verbose output of CLI imgcode called by GUI overlay, preview of input and output image and run button for generating gcode. Program is very simple and pretty straight forward. It resembles first version of imgcode I made in MATLAB/Octave language (which source code I lost due to HDD failure).

    I made exec versions for x64 Windows users. They are in dist folder.

View project log

Enjoy this project?

Share

Discussions

Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates