You might want to read the first two articles in this series on working with files to prepare them for waterjet or laser cutting: The Difference Between Vectors and Bitmaps and EPS, PDF, and SVG files.
We’ve covered all of the major file types except PNG, JPG, GIF and other raster format files. Raster files can be converted to vector/DXF format, but they take some fussing to get to the vector stage. In this article we'll see how to take raster and bitmap images and convert them to vectors. We'll take a look at a PNG file as an example, but the techniques should apply to any raster format file.
You’ll need 3 programs downloaded to convert a PNG. Luckily they are all free: Inkscape, Gimp, and LibreCAD.
PNG files can be converted to DXF using the tracing tool in Inkscape. That said, this works best on simple designs like rectangular plates with holes in them with low tolerances and organic designs for decorative objects. If you are working on a specialized plate that needs holes in precise places, PNG isn’t going to help you. If you are working on a crest for the chest plate in your cosplay armor, then PNG can be an avenue to a DXF of the part.
The Big Blue Saw online quoting and ordering tool supports raster files in the PNG and GIF format, but for maximum control over the finished part, including exact sizing of features and distances between holes, you will want to convert to DXF before uploading the design to Big Blue Saw.
At this point we have a crest and it is saved as a PNG.
First thing we need to do is open it in Gimp and set the color and edges.
We open our image in Gimp and from the menu bar choose Colors, and click on Brightness/Contrast.
Set the contrast as high as it will go (red arrow). Don’t adjust the brightness. Click OK.
This sharpens the edges of the part.
Next we need to index the colors to just black and white.
Go to Image, Mode, Indexed. Click the radio button for black and white 1 bit palette and click Convert.
Now we have a file we can trace in Inkscape. Export it or do a Save As a PNG file and open the file in Inkscape.
Now if you look at the edges closely, they look a little rough. This is normal on a converted file. When Inkscape traces the outlines, they will smooth out a bit. That way we will have really sharp edges and an all black image.
Here's a closeup of the image so you can see the individual pixels:
Now open your new PNG file in Inkscape and click on the image.
See how the resizing arrows are around the document edges and not around the crest itself? That is one hint that we aren’t dealing with a vector image.
So go to Path in the menu bar and select Trace Bitmap.
Make sure your image is still selected. In the pop up window, you’ll change a few settings to get a nicer trace.
The brightness cutoff is usually pretty good for tracing black images, so you can leave that radio button selected. Check the Live Preview button so you can see if the settings are warping your design really crazily.
I usually bump the threshold up above 0.550 but below 0.999. With live preview checked you can see if your design is starting to look clunky. Then click OK and Inkscape will trace your design.
Now you have a vector image from a bitmap/raster. We can see this by changing the View to Outline Mode.
There are now two versions of my crest in this file. The bitmap that was in the PNG, and sitting on top of it is a vector. I usually select the bitmap and delete it at this point.
Then File and Save As. From the file extensions list, choose DXF.
For simple shapes, you can likely upload the resulting DXF straight to the front of our website and check out. But sharp corners like the ones in my crest have a tendency to get a few extra lines when you save as a DXF in Inkscape. They can be cleaned up easily in LibreCAD though, so a quick clean and a save and then this will be ready for the big leagues.
Open the DXF file in LibreCAD:
See the extra lines? They're highlighted with red arrows in the zoomed in image below.
Click on all of them one at a time to select them.
Then go to Modify in the menu bar and select Explode at the bottom of the menu.
Now click on all of the extra lines to select them. Then hit the delete key to delete them from the file.
Now I resave as a R12 DXF file using the same name.
At this point, you can make any other adjustments to the scale, sizing, or outline path to make sure that your design is exactly how you'd like it to turn out when it's made into a real part. Now that it is cleaned up and good to go, time to upload to the website for a quote.
If I don’t have any errors, it will upload cleanly. If there are errors, then the website will give me an error message. If you get that message on your drawing, there is usually an orange link that will take you to a diagnostic view of the part. Click the diagnostic view and use it as a way to troubleshoot your way through whatever is hanging up the quoting software. If the quoting software can’t read it, the laser and the waterjet can’t cut it.
Yay! It worked. Now take a quick look at the size under the rendering of the part.
When I designed this crest, it was a little smaller than what is showing up on the website. This is common with traced files. The line width of the ellipse tool I was using added to the crest’s size. This can also go the other way in a traced file, where the part is showing up larger than drawn due to line weight. Be sure to carefully check your part’s size at this stage.
If the sizing would make a difference in my costume, I would click the Resize button, and enter a new width or length. The resizing button on the website proportionally scales parts up or down using the measurement you enter first. In this case, it isn’t an issue, so we move on to the materials list.
And choose a material.
From this screen I can get pricing for cutting multiples of my crest, see renderings of my part, and check the Part Details at the bottom of the screen.
Always check the Part Details to make sure the measurements look good, the renders look like the part you want to cut, and that the correct number of holes are listed. Then enter the quantity of parts you want in the quantity box, and click Order Custom Parts to checkout through the website.
And that is how you turn a PNG into a DXF vector file. A bit fiddly and not great for precision parts, but good for parts that have a little wiggle room on the tolerances. It also makes a good introduction to Inkscape and LibreCAD as programs, which can help you skip tracing PNGs for future projects.