Image to Laser G-Code Generator

This tool turns a photo into raster engraving G-code for a GRBL diode laser: it resizes the picture to one dot per line interval (0.1 mm = 254 DPI), dithers it and writes M4 laser moves with overscan. Your image stays in your browser and is never uploaded. Published November 1, 2026.

1. Image

Drop an image here or click to choose
JPG, PNG, WebP, GIF or BMP
No image loaded yet.

2. Size and resolution

1 dot per line interval in X and Y.

3. Image processing

4. Laser and G-code

Your controller needs laser mode on: send $32=1 once. The max S value must equal your $30.

Engraving Preview

Load an image or try the example
Black dots burn; white is left alone. In grayscale mode darker grey means more power.

Download

The PNG has exactly one pixel per line interval and carries its DPI, for LightBurn or LaserGRBL users who prefer to import an image.

Check the file in the G-code viewer before you run it, and frame the job with the laser at low power.

First lines of the G-code
-

How Photo Laser Engraving G-Code Works

A diode laser can only burn or not burn each spot, so a photo has to be turned into a pattern of dots first. The picture is resampled so that one pixel equals one line interval, the grey tones are turned into dots (dithering) or into power levels, and each pixel row becomes one back-and-forth pass of the laser head.

This page does the raster engraving job only. To cut shapes out, trace the outline to vectors with the Image to DXF Converter; to cut text or serial numbers with a spindle and engraving cutter, use the G-Code Engraving Generator. For carved relief in wood with a V-bit, see the planned image to V-carve G-code tool, and for 3D printed light-through photos the image to lithophane generator.

The Method

1. Size and resolution
dots across = width ÷ line interval
DPI = 25.4 ÷ line interval (mm)
0.1 mm is 254 DPI, 0.08 mm is 317.5 DPI. The photo is averaged down (or smoothly scaled up) to exactly that many dots, then brightness, contrast, gamma, sharpening and invert are applied. The limit is 4 million dots.
2. Dithering
Error diffusion (Floyd–Steinberg, Jarvis, Stucki, Atkinson) sets each dot black or white and passes the rounding error on to the dots not yet done, so the average tone survives. Serpentine scanning runs every other row backwards to stop diagonal "worm" patterns. Bayer uses a fixed 4×4 pattern; threshold is a plain cut at one grey level.
3. Power
dithered dot: S = $30 × max %
grayscale: S = $30 × (min % + (max % − min %) × darkness)
Darkness runs from 0 (white) to 1 (black). In grayscale mode pixels lighter than 250 of 255 are left off so white backgrounds are skipped.
4. Moves and time
line length = burned width + 2 × overscan
time ≈ G1 length ÷ speed + G0 length ÷ rapid rate
Each line starts with a run-up at S0 so the head is at full speed when it reaches the image, and runs out past the end at S0. Dots of equal power in a row become one G1 move. The estimate leaves out acceleration, so real jobs take a little longer.

Laser Mode ($32=1), M3 and M4

GRBL 1.1 only behaves as a laser controller with laser mode on. Send $32=1 once (it is stored). With laser mode on, GRBL switches the beam off during G0 rapids, keeps moving without stopping when only the S value changes, and allows M4 dynamic power. With laser mode off, the machine pauses at every power change, which leaves burnt dots, and the beam can stay on during rapids. $30 is the S value for full power (1000 on most diode lasers, 255 on some); set the Max S value box to match it.

M4 scales the power with the actual speed, so the start and end of each line (where the head speeds up and slows down) are not over-burned. M3 holds the same power all the time. M4 is the normal choice for engraving; overscan still helps with either.

Worked Example

100 × 80 mm photo, 0.1 mm line interval, 3000 mm/min, 5 mm overscan, bidirectional
  • Resolution: 25.4 ÷ 0.1 = 254 DPI. Dots: 100 ÷ 0.1 = 1000 across and 80 ÷ 0.1 = 800 down, so 800 000 dots and 800 lines.
  • Each line (if the picture fills the full width): 100 mm + 2 × 5 mm overscan = 110 mm.
  • Feed moves: 800 × 110 = 88 000 mm. Time: 88 000 ÷ 3000 = 29.3 minutes.
  • Travel: bidirectional lines step up 0.1 mm each, about 80 mm of rapids in all, a second or so at 6000 mm/min. Lines that are blank are skipped, so a photo on a white background is quicker.
  • Power: with $30 = 1000 and max power 80 %, every dithered dot burns at S800.

Line Interval and Spot Size

Set the line interval close to your laser's spot size. A typical diode laser spot is about 0.08 to 0.15 mm (check your laser's specification and focus it well), so 0.1 mm (254 DPI) is a good start. Much finer lines overlap and the picture goes dark and blotchy; much coarser lines leave stripes. Rule of thumb: on soft woods that char easily, a slightly coarser interval (0.12 to 0.15 mm) or a brighter image often looks cleaner.

Which Dither for Which Material

MaterialMode to try firstNotes (rules of thumb)
Light wood, birch ply, MDFJarvis or StuckiWood darkens as heat spreads, so raise brightness or lower max power. Grayscale can work on even, light woods.
SlateThreshold or Floyd–Steinberg, invertedThe laser turns slate lighter, so invert the image. Low power is usually enough.
Painted ceramic tileFloyd–Steinberg or AtkinsonResults depend on the paint and method; test whether you need to invert.
Black anodised aluminiumFloyd–Steinberg or Atkinson, invertedThe laser removes dye and leaves a lighter mark. Blue diode lasers mark dark anodising far better than clear or bare aluminium.
Card, leather (real)Stucki or Floyd–SteinbergLow power and higher speed; these mark very easily.
Logos, line art, textThresholdClean edges with no dot noise.

Practical Tips

  • Prepare the image first. Crop tight to the subject, remove or whiten the background (white costs no time), raise contrast a little and add a touch of sharpening. Faces usually need brightening because wood burns darker than a screen shows.
  • Run a material test. Engrave a small power and speed grid on an offcut of the same material before the real job. The laser engraving settings page helps you plan one.
  • Check the file. Open the G-code in the G-code viewer to see the size and position, then frame the job before burning.
  • Prefer importing an image? Download the processed PNG: it is one pixel per line interval and stores its DPI, so LightBurn sizes it correctly on import. Use LightBurn's Pass-Through image mode so it does not dither the dots again. In other software, type the size in mm to match.
  • Unidirectional if lines look offset. If every other line is shifted sideways, the machine has backlash or belt stretch. Turn bidirectional off (slower) or tighten the belts.

Laser Safety

  • Never laser PVC, vinyl or faux leather that may contain PVC. It gives off chlorine compounds that harm you and corrode the machine.
  • Watch the job. Wood and card can catch fire; never leave a running laser, and keep an extinguisher close.
  • Wear eye protection rated for your laser's wavelength (445 to 455 nm for most blue diode lasers). The orange lid or tinted glasses that came with a cheap laser may not be rated; check the optical density marking.
  • Ventilate. Smoke from wood, MDF and leather is harmful; extract it outdoors.

Frequently Asked Questions

Match the line interval to your laser's spot size. For a typical diode laser that is about 0.1 mm, which is 254 DPI. DPI is 25.4 divided by the interval in mm. Finer settings overlap the lines and make the picture dark and muddy.

Jarvis-Judice-Ninke and Stucki usually give the smoothest photos on wood because they spread the error over more dots. Floyd-Steinberg is a good all-rounder, threshold suits logos and line art, and grayscale power can work on light, even woods.

Laser mode lets GRBL change power without stopping, turns the beam off during G0 rapids and enables M4 dynamic power. Without it the machine pauses at each power change, leaving burnt dots, and the beam may stay on during rapids. Send $32=1 once and it is saved.

Use M4 for engraving. It lowers the power while the head speeds up and slows down, so line ends are not burned darker. M3 holds constant power, which suits cutting at steady speed. Overscan helps with both.

Most often the line interval is finer than the spot, the power is too high, or the image was not brightened for the material. Raise brightness or gamma, lower max power or speed it up, use a 0.1 to 0.15 mm interval, and run a small test on the same material first.

Spot sizes, material advice and starting power are typical values and rules of thumb, not data for your laser. The time estimate ignores acceleration. Always run a test on scrap, check the G-code before running it, and never leave a laser unattended.