Skip to content
Find a tool

Image to Gcode

Convert a picture into line-by-line laser G-code with the feed, power and spacing you set.

Free · runs in your browser · nothing is uploaded

Open on Outlinecut

This embed was switched off for this website. Open on Outlinecut

Add this tool to your siteFree embed code, no sign-up. Keep the credit link.

Embed this tool

Copy this code into your website, blog or class page. The tool runs inside your page.

Optional settings, added to the address after embed=1: &accent=0f6b5c (colour, 3 or 6 hex digits). Other parameters are ignored.

Please keep the credit link below the tool.

This image to gcode tool makes GRBL-style raster engraving files. The picture becomes parallel scan lines, and every pixel on a line turns the laser on or off, or sets a power level between the two. You choose the width in millimetres, the spacing between lines, the feed rate and the laser power, then download a .gcode file for a diode laser or a GRBL machine with a laser fitted. Before downloading you can read the number of scan lines and the estimated engraving time. The tool does not write milling toolpaths or depth-map carving. It has not been run on real machines, so test every file on scrap material first.
Image to gcode example

How to use the Image to G-code tool

  1. Drop an image on the tool, paste one, or press Choose image. Try a sample loads a demo picture.

  2. Set Width (5 to 600 mm, default 60). Height follows from the picture’s proportions.

  3. Set Line spacing (0.05 to 1 mm, default 0.1). Smaller values give finer detail and more lines.

  4. Pick an Engraving style: Black and white (dithered) or Gray levels (power varies).

  5. For black and white, choose a Dithering method; Floyd-Steinberg is the default.

  6. Adjust Brightness, Contrast (both -100 to 100) and Gamma (0.3 to 3) until the preview looks right. Tick Invert if light and dark are swapped.

  7. Set Laser mode to M4 dynamic power or M3 constant power.

  8. Enter Feed rate (100 to 12000 mm/min, default 3000) and Laser power (S) (1 to 1000, default 800).

  9. Check Scan lines and Engraving time (min) under the preview, then press Download G-code.

  10. Open the file in your sender software, put the work origin at the bottom-left corner of the picture, and run a small test on scrap material before the real job.

Coordinates run from X0 Y0 at the bottom-left up to the full width and height. The 2 mm overscan reaches up to 2 mm past each end of a line, so X can go down to -2 mm: leave 2 mm of free travel on both sides or move the origin in by 2 mm. The file finishes with M5, a move back to X0 Y0 and M2.

How to turn a picture into G-code?

The picture is resampled to your width and line spacing, converted to gray, and either dithered to black and white or kept as gray levels. Each scan line is then written as G-code moves with a power value per stretch of pixels. Empty stretches are skipped, so the laser does not travel along blank areas at engraving speed.

Here is the order in which the program is built:

  1. A short header: G21 (millimetres), G90 (absolute moves), M4 or M3 with S0, and your feed rate.
  2. One pass per scan line with burned pixels. Direction alternates, with 2 mm of laser-off run-in and run-out at each end.
  3. Runs of the same power merge into one move, and gaps are crossed with G0 moves.

How many lines will the job have?

The number of scan lines is the picture height divided by the line spacing, minus any lines that contain nothing to burn. Halving the spacing doubles the line count and roughly doubles the time.

HeightLine spacingLines (at most)
60 mm0.2 mm300
60 mm0.1 mm600
60 mm0.05 mm1,200

A check you can redo by hand: a picture 40 mm wide and 20 mm high with one solid black block of 10 x 4 mm, at 0.2 mm spacing, gives 4 / 0.2 = 20 scan lines, each burning 10 mm plus 2 mm of laser-off run-in and run-out at either end. That is 20 x 14 = 280 mm at 3000 mm/min, about 6 seconds, and white areas get no lines at all. Your picture will give different numbers.

Which engraving style should I use?

Use Black and white (dithered) for photos on most diode lasers, because every pixel is either full power or off. Use Gray levels when you want darker pixels to get more power and your laser responds smoothly to S values.

OptionWhat it does
Black and white (dithered)Full power or nothing, with tone built from dot density
Gray levels (power varies)Darker pixel, higher S value up to your power setting
Floyd-Steinberg, Atkinson, Jarvis, Stucki, SierraError diffusion; Floyd-Steinberg is the default
Bayer 4x4, Bayer 8x8Ordered patterns with a regular texture
No dithering (threshold)A single cut-off between black and white

Which power and speed should I use?

There is no single right value, because it depends on the laser, the lens and the material. Start from the defaults of 3000 mm/min and S800, engrave a small test at the same line spacing, and change one value at a time. The tool allows S values up to 1000, so check what maximum your controller expects ($30 in GRBL) and keep the setting within it.

Which machines can use the G-code?

The file uses plain GRBL-style commands, so it suits controllers that run GRBL in laser mode. GRBL must run in laser mode ($32=1) for both M3 and M4: the file crosses blank stretches with G0 moves, and only laser mode keeps the beam off during G0. With $32=0 those moves burn a line, and M4 does not lower the power at slow speed. A CNC router can run the moves, but M3 and M4 then start the spindle, so only try it with the tool removed or after reading your own setup carefully.

Answers to common questions

Can I convert PNG and JPG directly to G-code?

Yes. Drop or choose the file and your browser decodes it before the tool converts it to gray.

What happens to my photo?

It is read and processed inside your browser, and your input is not uploaded to a server.

Does it create depth-map or milling G-code?

No. The output is raster engraving only: laser on, off or at a power level along straight scan lines. There is no cutting depth, plunge feed or tool diameter.

Do I need to change a GRBL setting?

Yes, for both laser modes: turn on laser mode with $32=1, because blank stretches are crossed with G0 moves that must not burn. With M4 the power also scales with the actual speed; with M3 it stays at the set power while the head accelerates and slows.

How long will the engraving take?

The page shows Engraving time (min) from the engraved distance and your feed rate. Real jobs run a little longer, because machines accelerate and slow at the ends of each line.

Where does the laser start, and what does the file end with?

Coordinates start at X0 Y0 in the bottom-left corner and the first line sits at the top of the picture. After the last line the program turns the laser off with M5, returns to X0 Y0 and ends with M2.

Can I run the file without testing it?

No. The output has not been tried on real machines here. Engrave a small test on scrap material, and check power, feed and your controller’s limits before every new job.

What does Invert do?

It swaps light and dark before conversion, which is useful when the laser should burn the light areas of the picture instead.