August 23 2022

Images to G-code.

CNC machines like routers or milling machines make use of a series of pre-programmed commands to create your workpiece. The most popular programming language is G-code. This language controls how your CNC machine’s tools move. From how fast your tools move to the speed of rotation, everything is covered in the G-Code language.

These machines only work with vector file formats or G-code. You can see why, then, you can’t simply take a image PNG and automatically use it with your CNC machine. Fortunately, conversion software like Ultimate CNC can trace your image and convert it to G-code.

Then, Ultimate CNC transforms your digital image to G-code that you will be able to process directly with your CNC machine. It supports common image formats, but it depends on your system. So, the best option is Webp. WebP has been developed for Google as a replacement for JPEG, PNG, and GIF file formats.

From release 3.2.4, the image's digitization will be able to convert to G-code using G00, G01, and G02.

Image to G-code is useful to create some logos or templates. You have many images available on Google Images ready to process on your CNC machine, but not all images are the best candidates to do this conversion. Read the "Tips for converting Images to G-Code" chapter. 

Converting Image to G-code:

icon load gcode

When you open your image file, a new screen appears with all the information you need to fill in to generate the G-code:

image to gcode configuration

Depth of your material.
Depth steps
Depth for each step, it will end in full depth.
Z up travel
Z axis position when your cnc machine is moving to mill.
Set Origin
Set the origin near the part. If you turn it off, the origin point is at the bottom left of your image and considers all pixels "empty".
Trace inside first
Ultimate CNC will attempt to mill internal shapes and then external shapes. Enable by default.
Trace optimize
Ultimate CNC will try to find the best path to mill your part. Enable by default.
Precision (1)
Before generating the G-code, the Ultimate CNC checks the distance between the points, and if it is too small, these points will be removed. It is necessary so as not to fill up the Grbl planner buffer. Minimum recommended 0.1/0.2 or greater, this value depends largely on the feed rate used. This value is in mm, real distances between points.
Arc detection
Ultimate CNC tries to discover circles on your image and will use to generate the G-code. This value is scaled to %. You can disable this functionality by setting a value of 0. The recommended value is 5%, but it is just a recommendation. The correct value has relation directly with the radius of circles that you want to detect and the quality/resolution of the image that you want to convert.
The problem with image transformations is the perception of pixels. As you know, images are made up of tiny dots (called pixels). This function will try to eliminate the pixelation problem. You should use this functionality if your image has a low resolution.
Precision (2)
To smooth pixels, the software uses an algorithm that needs to know how many pixels you want to smooth. We recommend a value of around 1.0. This value is a distances in "pixel space".
Size (width x height)
You must specify the dimensions you want to generate the G-code with. If you disable 'Set Origin' option, the size will take into account the shape of your image; otherwise, the size will be the full image, taking into account "empty" pixels.

image to gcode manufacturing

Shapes options
You can select some shape detected and remove it or remove everything except the shape that you selected.
Bouding box
You can add a bounding box. It is a rectangular border that fully encloses your image.
The tool compensation can be selected: inline, inside, outside. It is an offset of the shape detected to compensate for the diameter of your tool.


The following conversions, images to G-code, are performed using the last current release, 3.2.4.

Image to G-code using G00, G01

image to gcode grbl

Image to G-code using G00, G01 and G02

image to gcode grbl g02

Complex Image to G-code

To generate PCBs, we do not recommend using images. The printed circuit board has small tracks.

image to gcode grbl pcb

Tips for converting Images to G-Code

The best tips for success transformations:

  • It is recommended to use images with high resolution.
  • Images with fewer colors are probably the best option to convert to G-code.
  • Sometimes, it's better to use high-resolution images and set 'Smoothing' = false and Precision (1) = 0.1/0.2.
  • If you want to convert a low-resolution image to G-code, try setting 'Smoothing' = true and Precision (2) around 1.0.
  • Avoid using images that have shadows.