3D model .STL to .PNG preview


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.


Join the Conversation


    1. Are you asking about a command-line tool to batch-generate previews, or would GUI-based g-code simulators work for you?

  1. 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 comment

Your email address will not be published. Required fields are marked *

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