Hey! This thing is still a Work in Progress. Files, instructions, and other stuff might change!

ImageToGcode Converter for 3D Printer / Laser Engraver / Plotter

by VICLER Dec 22, 2017
Download All Files

Thing Apps Enabled

Please Login to Comment

Hey , hi from Turkey.
I have a request for some options.
I have a custom laser engraver. Its working with GRBL card. But my laser works some crazy. So in normally lasers work power with 0-255 ( S0 to S255 Command) But my laser and my software working with S0 to S2000 . So i cant calibrate the laser power. When GCODE in max S is 255. And my laser dont wprk under s80 .

So , can you add an option for Laser Power Command. Like

Max Laser Power : Sxxx
Min Laser Power : Sxxx for example.

Is that possible?

Thank you and well done. This sofwware is the best converter IMG to GCODE i have ever see :)

Im waiting your reply.

Have a Nice Day

Hi Badubey!
It is easy to implement, but this app is designed for 3D printer firmware like Marlin or Repetier etc. and I think they all use 8bit pwm by default.
But I will think about that, because it will be helpful for some peoples, who have powerfull lasers and >8 bit pwm resolution.

So, if I understood it right, you have GRBL firmware on your machine? If so, then you definately have to try LaserGRBL software. It is much powerfull and was designed especially for GRBL firmware. ImageToGcode is not supporting GRBL.

Yes , Im using gbrl. And yes I am using laser gbrl software. But unfortunetşy lasergbrl doesnt convert images to gcode like yours. And the other softwares creating gcode point to point..There isnt lines. Just dots.

Buy the way your sofftware output files working fine with GRBL. But only issue is like i said , S command. I think im not the only one having this issue.

I hope , you will give the solution for us.
I think its just adding min and max levels with S value. If i type 255 , max is S255. If i type 2000 , max is S2000.

I cant find any "alternatives" equal your final file quality.

I have also modified the LaserGRBL app for using it with 3D printer GCodes, and I have not noticed the differencies in quality between this two apps.
And really? GRBL is supporting 3D printer GCodes? Very nice! I don't knew that. I thinked it is not supporting this style of GCode and for 99% of users your request will be unusefull. But then, I think I will release a new version soon :)

Yes , app is suporting your app's gcodes very nice. I will add photo wednesday :)

And im waiting excitedly your new release

Hi, Badubey!
I have just added the option for adjusting max pwm value. Just double click on "Max Power: ... %" label and enter your value. Have fun! ;)

Wow, thanks for this tool...its great the first one which works
can you maybe implent a function which allows to save the gcode in an specific folder? That would be awesome.
This picture is of my first try...pretty good so far

Hi! Thank you!
I am thinking about to change the destination of the generated GCode to original picture location. I think it will be easier to find the GCode.

Im only getting the shading of the picture no details or lines just a shadin of the picture

Can you sent me the generated Gcode file?

How do you get the code once I click on generate gcode it doesn’t make it

You find the GCode file in the same folder, where you start the app.

This software is giving me the best potential results with my printer to laser mod running Marlin. However, early into the print I'm running into serious problems with motion control. It starts jumping around all over the work piece in seemingly random patterns. See image: https://ibb.co/rytdddS

EDIT: I had the speeds up too high for my electronics to keep up with. Your software is fantastic!

Thanks! I'm glad you like it!

i want to use a pen instead of a laser, but there is no Z Hop , could you please help me out

Take a look at the comment from vdubadub below ;) there you find the commands for z-hop.

This is great! Thank you! I've been running it on Wine on my linux machine. Playing around with my printer as a pen plotter. G90 as the header for absolute positioning. G1 Z0 as the laser on command to draw and G1 Z0.7 as laser off command to pick up the pen. Obviously using 1-Bit color. Would be so cool if it could use cross hatching to emulate a kind of grayscale!

Hi, vdubadub! You are welcome!
I also played a little bit with a pen for drawing
I can suggest you to edit your image with some halftone algorihms and then convert it to Gcode with 1-Bit color. Here for example: https://xoihazard.com/tools/halftone/

This is a great software, thank you very much!

You're welcome!

I'm trying to use it on a CTC I3 Pro B modified printer, replaced the print head with a 4W laser, for which i made a mount (https://www.thingiverse.com/thing:3417652) and i'm trying to get rid of the dark margins caused by deceleration of the laser on X but PWM stays high, doesn't compensate, and i'm trying to find the max acceleration so printer spends as little time as possible at the beginning and end of each line...

Laser mount for CTC I3 Pro B 40x40mm laser profile
by Razvitm

Hi, Razvitim!
Yes, I know about this problem.
To fix it I will add a "Pass extension" option in near future.
Hope you enjoy it! Good luck!

At the end of this page ( https://www.prusaprinters.org/calculator/ ) there is a graphic calculator which tells you after how many mm your CNC head will reach a desired speed based on acceleration you provide. It's useful to calculate the length of the "pass extension" for each CNC machine. Also, thank you for the software, please continue developing it. Meanwhile i will try to find out how to edit a .gcode file generated in LaserGRBL in notepad++ to make it look like a file generated with ImageToGcode... If i find a way and it's repeatable, i will make a video tutorial and post it to youtube, so others can use LaserGRBL on Marlin based printers... AFAIK noone does that now.

Thanks for a calculator, it will be helpfull!
I have a good news for you :)
I modified LaserGRBL couple weeks ago for generating gCodes for Marlin. I posted the link on V1 forum, that mordiev mentioned in comment below. Here is the link to download: https://mega.nz/#!FslSUKIQ!PwdQzEIgfobTeFqY7bnPAJ4KTfN4al1FbNpqkKoL82s
Although it cannot be used as host, only as GCode generator.

How do I run it on Windows?
Edit: Found it... \LaserGRBL\bin\Debug\LaserGRBL.exe
I see you've added M106 command option, nice!

Go to: LaserGRBL/bin/Debug. There you find an executable for Windows

What's the difference between M106 and M106 P1 command?

The M106 controls the first FAN by default. If you have more fans attached to your 3D printer, you can control them with M106 P1, or M106 P2... M106 is the same as M106 P0

Hello Viktor,
I really like the app. Well done. I first learned about your app from the link to it that you posted in the V1 (Vicious 1 Engineering) forums. I have tested it on my MPCNC and found that it sadly won't work for me or other MPCNC users for most images. Could you please join the conversation in this thread back on the V1 forums? https://www.v1engineering.com/forum/topic/image-to-gcode-converter/

I would love to use this app but I would need to ask you for some tweaks. I know that Ryan is looking for an app to feature on his instruction pages on how to install and use a laser. Right now I am testing apps like this and giving Ryan some recommendations on what app he should feature.

Thanks for you app! Are there any specific Start and End Codes I should use with Prusa i3 MK3?

You're welcome! Very usefull Start GCode is ''G92 Xx Yy'' for setting laser point offset. To find this values you have to home X and Y axes and then measure the distances from origin on your bed to laser point.
For the End-GCode you can use G0 Xx Yy to move the laser to park position after engraving is done.
Have fun!

This looks pretty great, and intuitive. I'm sure it wasn't your intention, but I don't have windows (or mac), so I ran this in wine. It's actually working alright! Things aren't laid out perfectly, but it's completely usable. One thing that tripped me up is that it just puts the gcode next to the image. I don't have my laser up and running yet, but the gcode looks good to my eyes.

Have you considered sharing the source code on github or bitbucket or something similar? You might be surprised at the support you'd get there, and maybe even find some developers interested in submitting fixes or improvements.

Hi Jeffeb3!
I'm glad you like it! Currently my old laser is dead, and I do not have installed the new one so I debug my GCode by using this online GCode viewer https://ncviewer.com/. I find it very usefull.

Yes, I was thinking about github, but unfortunately at the moment I do not have enough free time to figure out how it all works. But I will definitely do it in the future.

I have seriously been banging my head against the wall trying to figure out how to do all of this in Gimp, Inkscape, Fusion360, etc. And this itty-bitty little program does it all in one step. Awesome work! Thank you for uploading this.

You're welcome! ;-)

Comments deleted.

Great stuff! Exactly what I was looking for. The pictures I have made so far came out perfectly.

One more good feature to add would be a duration forecast based on size, feedrate and travelspeed.

Runtime forecasting is a good feature, correct, but it can not be accurately implemented because it also depends on the accelerations, and they are different for different 3D printers. Does your Host App not show the estimated time? I use Repetier Host and it can forecast ETA.

Love the app. However, am I doing something wrong? The image preview if normal is fine. However, the burn is exactly inverted. If I hit Invert.... the preview image is inverted and the resulting burn is as well. Is the generated gcode broken and only sending inverted burn pattern?

A little more testing.... it looks to be on a solid black (not 1 bit)... Trying to do a grayscale type photo.... when it does the Solid Black at full power (255 is max) ... it is traveling at the Fast Travel speed that would be for white areas. Then the more grey areas, it seams to burn appropriately. White areas are completely off and travel past fine. Is it something with the solid black areas / travel?

Hi! First of all thank you for sharing your experience! Do you use the actual version in Downloads section? I have tried to generate the gcode, and it works, like expected. Can you share the image you trying to convert and app screenshot with parameters?

Yes. I used what you have in the download section. I am not home to screenshot the settings. Off the top of my head... min laser 25, max 255. Feedrate 4k. Travel 10k. Resolution 0.15. White offset... I think I just clicked in the image on a bright area. As stated above, the black pants... when it turns the laser on for that area, it looks to be at full power. However, the travel speed is fast over the pants. I went lighter on my settings before (min 15, max 70) and because of the travel speed, the pants didn't show at all.

Ou yes, it looks overburned. You have to calibrate the laser power for different surfaces, speeds and resolutions. I have reached best results with with HDF(high-density fiberboard). To calibrate the laser power I suggest to do following: find in web a grayscale calibration image (something like this one http://aftar.uaa.alaska.edu/images/ramp.gif) and play a little with min laser power and max laser power with constant burn speed that you prefer. For faster speeds the min and max values have to be higher. But the max burning speed for grayscale images depends also on pwm resolution of your laser controlling pin. So start with lower speeds and increase it until you see quality bugs. And one word about resolution. The smaller is the resolution value the "darker" is the result with constant min and max power values.
Sometimes it is hard to calibrate all parameters for perfect grayscale results using pwm. I have found an alternative method to make garyscale images with only one-bit color. It is called dithering. I plan integrate some algorithms to my app for this methods if I have enough free time for that. Maybe you can convert your image to grayscale using dithering on some online web platforms, or using inkscape and then convert it to gcode with my app with one-bit color parameter.
I wish you success!

I do understand all of this. However, why would it decide to go FAST speed over the darkest part? Regardless of my settings, it should be the SLOWEST speed over the darkest part to allow more burn in.

If its possible I would see your generated gcode and screenshot of the app. Currently I cant explain such behaviour, sorry. I will try to fix this and other bugs soon as possible. Thank you!

No problem. I get it. i'm a software developer by day. I just haven't taken the time to do exactly what you've done with this app. I'm not one to re-invent the wheel unless what is out there is totally bad. I like this app though!

Are you sure, that it moves with travel speed over the pants? To debug the generated gcode I always used this gcode visualizer https://ncviewer.com/ and I see on that area is everything ok with the speed and laser power. So I think your problem is the surface. I also had problems with such piece of wood. If its possible try another woodpiece with constant surface. Like I said above hardwood was the best for my grayscale pics.

I went ahead and hit the visualizer like you sent above. However, if you hit play and watch the tool path... it moves fast over the pants... or skips steps over the pants.

All I know is that over the pants it does travel faster than the gray areas you see that are very dark in the result. As stated above, if I turn the intensity (max) down to around 100 or so, the pants are not even burning. This is on various test areas of the board, not just that specific surface. I will work on a video some time this weekend. It slows down over the gray and goes fast over that solid black area of the pants.

hmm.. This visualizer doesnt show real speed, witch your laser head moves on, it shows only the speed changes with colors. On blue areas it will be moving with constant burning speed, and orange areas will be passed (with travel speed). The GCode is ok, but I think I know, what your problem is. Acceleration speeds in your 3D printer firmware. If you look on Gcode, you will see, that on gray areas it makes very small moves with different laser power values (its a piece of your gcode)

M106 S198 // laser power 198
G1 X40.96 Y6.24 // x position 40.96mm
M106 S196
G1 X40.8 Y6.24 // moving 0.16mm to position 40.8
M106 S197
G1 X40.64 Y6.24 // moving 0.16mm to position 40.64
M106 S198
G1 X33.76 Y6.24 // and here it starting to move over the pants. Its 6.88mm !! So it is long enough to reach the max burning speed you entered in app configs with your X Axis max acceleration. But due to this acceleration the laser head cant reach the max speed by moving such small distances like above

So the solution for your problem may be increasing the acceleration of your X Axis in firmware or EEPROM, or setting lower burning speeds and lower laser power values in the app.

So what you are saying is that it is a continuous path run that will default to the speed set as max x instead of you "pulsing" each pixel as individual lines of code. I suppose that would make the gcode file way huge. I don't think hardcoding a max X speed in the firmware is something that should be done for keeping a solid laser run reduced. I do believe there is a MAX X gcode that can be sent as a starting code parameter.

Would you be willing to modify the code to the see the intensity above a certain number (in this case S198) and force a F code for speed to be at least the Feedrate? Then I can adjust the max feedrate for the code easily?

yes, grayscale images contain a lot of neighbour pixels, that can be differ in just one color bit. The more neighbouring pixels with differ colors the picture has, the more code lines it will be.
I think you did not understand me. As you saw in gcode analyser, all the blue lines have the same speed. That is feedrate you set in the app. But the problem is that due to firmware limitations, the X-axis can not move all the blue lines at that speed (I'm 99% sure because gcode is correct).It achieves this feedrate only for long lines containing pixels of the same color, and if your laser can not burn the wood at that speed, it is too fast or the maximum laser power is too low. I recommend you to find the right maximum feedrate for max laser power first (for black color). Use a simple black image for that and increase the speed each time untill it gets brighter. Or you can send simple raw gcode to your machine

I'm still tinkering with this. However, the software developer side of me thinks it could be done better in the software without so much thought behind the user. If a bunch of neighboring dots cause the laser to "hover" in that area longer... adjusting intensity for grayscale, the longer time will cause it to be darker. But a move over a larger area even at high intensity will not be as dark because of the fast move. I think the algorithm should maybe be a little smarter. If only doing a dot or a couple dots in a small area.... maybe set the speed high depending on the intensity. Then for the fully dark areas that are covering a large area.... like 6mm in a row without a change in intensity.... maybe slow them down. Feedrate being "maximum" feedrate / speed. But the software could figure out if it's moving from the previous spot for 6mm, but the area is the darkest / max intensity, it could set the F speed of the gcode slower. Compensate for the fact that it's not hovering over dots like it does at gray.

My issue is just that. I have the feedrate set at 100. Very very slow. But the gray around the pants is burning just as intense as the pants themselves. I feel we could accomplish it better with adjusting both the intensity and the speed. If you know what I mean?

Yes I understand what you mean. I thought about this method (grayscale with speed changes) when designing the app. This method has its advantages such as reducing the engraving time and no need for PWM. If I have more free time, I would try to implement this method in the app.
So with 100 feed your pants are now black? Then you are in the right direction, but the calibration is still ongoing. And what is your minimum laser power?
Now back to calibration. Set the laser power to 0. Try to increase the feedrate until your pants are brighter. You must set the feed rate so that large black areas on the image are black enough for you and the feedrate is as high as possible. So, if you find the right feedrate for the black areas, you can now adjust the brightness of the gray areas by adjusting the min laser power. The larger the value for the minimum laser power, the darker are gray areas on the resulting image.
And can you also tell me your maximum speeds and accelerations for your X-axis? I just want to compare it with my settings.

At 100 yes. It stays in the pants area long enough to burn. The problem is the gray areas are also black fully due to them staying there for a longer time. I'd rather have the max speed high and the darker the area / time staying in that area be correlated. I believe I had the laser power minimum set to 0 and max to 120 or so. I'd have to look again. Mind you... part of my issue could be that it is a 4W laser. The power shouldn't need to be near full power to burn properly. If I get another chance to play with the settings I will. I believe my Max speeds are 100mm/s on X... but again... I'll have to look.

Yes, the 4W laser has a lot of power, so you should reduce the maximum laser power in the app.

I'll look into that. Thanks.

Comments deleted.

Where is it saving the G-Code?

it will be generated in the same folder, where the app is located

Just what I've been looking for, thank you.

You're welcome!