3D model .STL to .PNG preview

Posted on Wednesday, May 13th, 2015 in #liveupdates, site by Ian


Bing search sucks.

Tried a bunch of ways to get image previews from 3d model .STL files. OpenSCAD does a decent and fast preview, but you gotta figure out where to put the camera for a good scene. The Linux repositories with OpenSCAD are outdated so you have to compile from source. Fire it up and it needs an Xserver and OpenGL, which are an additional install on most servers.

Looked at stl2pov, used by thingiverse to go from .stl->.pov and then render with the open source POV-Ray. From there to stltools, an improved version in Python. Renamed incorrectly named files, installed Numpy dependencies, couldn’t get it going.

Completely by accident found libre3d/render-3d which rolls all of the above into a .PHP script we can run server side. It coverts .STL to .POV using techniques similar to stltools, adds grid and calculates a camera position, then renders it through POV-Ray. Exactly what we would have cobbled together, eventually. Thanks Open Source!

Windows boxes running XAMPP are my go to for web development. Installed POV-Ray and got the render-3d scripts by composer. Worked on first try, but POV-Ray stayed open and blocked the script from finishing, a common issues running Windows app with a GUI from PHP. Around line 51 of Povray.php tag an /EXIT onto the POV-ray execution options to force shutdown: $cmd.= ” /EXIT”;.


render-3d doesn’t actually do well with our test model. The camera position isn’t very well chosen, but that’s something we can work on later. The rendering looks much nicer than OpenSCAD.

Bing, you suck. Google would have given modern relevant results first, not ten pages into a vaguely related search.


This entry was posted on Wednesday, May 13th, 2015 at 4:41 am and is filed under #liveupdates, site. You can follow any responses to this entry through the RSS 2.0 feed. You can skip to the end and leave a response. Pinging is currently not allowed.

4 Responses to “3D model .STL to .PNG preview”

  1. arekm says:

    Is there anything that can do gcode -> image?

  2. ben says:

    Have you seen Assimp/open3mod? It loads many formats into a common data structure that can then be loaded into an opengl renderer.

    PyQt with opengl gives you a nice library that can create a Qt gui which opengl can be rendered into, but it still requires code to do load the meshes into vertex buffer objects and write a shader to render them.

    For ex. here’s an old c++ tutorial that uses Assimp to open a 3d file, and OpenGL/GLSL to view

    I personally would like an easy way to convert .step files into COLLADA then .fbx so that it retains all the color

Leave a Reply

Notify me of followup comments via e-mail. You can also subscribe without commenting.

Recent Comments

  • Stephen Tinius: Thank you.
  • KH: Ah, the site sells boards, that's the reason. At least it's a XC6SL9 board that does not cost an arm and a leg, though it...
  • Max: While I understand this is more educational than practical in nature, I prefer my edutainment a lot more firmly grounded in economic reality. Sure, you...
  • KH: Using an alkaline coin cell down to 1.0V or under is a very bad idea anyway, unless you as the designer or manufacturer don't care...
  • KH: Farnell says TS1001 is no longer stocked. Not on RS. Digikey says it's obsolete. That said, there are a lot of nanoamp-class parts on sale...