<p>Typically you would install a (free) 3D model program as Fusion 360, FreeCAD, or many more options to choose from. Once installed, import the STL file and use menu options to export a picture of your STL.</p>

<p>Alternatively, if you have some programming skills, you could <a href="https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/Importing_Geometry" rel="nofollow noreferrer">import the STL file</a> in OpenSCAD and render and export a picture from there. Simply create an OpenSCAD file with the code line below and it will import your <code>example.stl</code>. </p>

<pre><code>import("example.stl", convexity=10);
</code></pre>

<p>Through the menu you can then export the view to an image. Note that you can do that also from the <a href="https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/Using_OpenSCAD_in_a_command_line_environment" rel="nofollow noreferrer">command line</a> as shown by the OP's own answer (nice example of command line usage of OpenSCAD).</p>

<p>These are not the only options, there are many more. E.g. <a href="http://dangerousprototypes.com/blog/2015/05/13/3d-model-stl-to-png-preview/" rel="nofollow noreferrer">this</a> is a nice example. It also describes how Thingiverse.com does STL to web image.</p>

CC BY-SA 4.0
2021-08-24T15:16:47.163Z
For those looking for a nautilus thumbnailer using this technique, I've written a quick one here: https://github.com/sbrl/nautilus-thumbnailer-stl/
starbeamrainbowlabs
CC BY-SA 4.0
2018-05-28T06:18:21.070Z
2018-05-29T18:25:44.667Z
2018-05-29T18:25:44.667Z
0scar
<p>If you don't mind using screen grabs,  you could use AppleScript or whatever it's called in the latest MacOS versions to build an automated script to open each file, grab screen, save, etc.  </p>

CC BY-SA 4.0
2018-05-28T16:32:12.680Z
2018-05-28T16:32:12.680Z
Carl Witthoft
<p>You can use OpenSCAD, as stated in the accepted answer. 
Here is a version of that script that works for Windows for anyone who needs it, as I did.</p>

<pre><code># Change height and width to the desired output image dimensions, in pixels.
# The path to openscad.exe may also have to be adjusted based on your installation.

height=1080
width=1080

for i in *.stl; do
  T=__tmp__<span class="math-container">$i
  b=`basename "$</span>i"`
  echo import\(\"./<span class="math-container">$i\"\)\; &gt; "$</span>T"
  C:/'Program Files'/OpenSCAD/openscad.exe -o "<span class="math-container">$b".png --autocenter --viewall --imgsize=$</span>width,<span class="math-container">$height "$</span>T"
  rm "$T"
done
</code></pre>

CC BY-SA 4.0
2021-11-04T18:15:15.197Z
What does the `echo import\(\"./$i\"\)\; > "$T"` line do? I'm trying to convert files with spaces in their names but keep getting various errors.
erdostamasa
CC BY-SA 4.0
2019-08-14T03:13:31.510Z
2019-08-14T03:13:31.510Z
Paul
<p>If you have <a href="http://www.openscad.org" rel="noreferrer">OpenSCAD</a> installed, this shell script will generate 100x100 pixel PNG images for each STL file in your current directory.</p>

<pre><code>for i in *.stl; do
  T=__tmp__<span class="math-container">$i
  b=`basename $</span>i`
  echo import\(\"<span class="math-container">$i\"\)\; &gt;$</span>T
  /Applications/OpenSCAD.app/Contents/MacOS/OpenSCAD -o <span class="math-container">$b.png --imgsize=100,100 $</span>T
  rm $T
done
</code></pre>

<p>Credit to <a href="https://3dprinting.stackexchange.com/users/5740/0scar">0scar</a> for pointing out STL files can be imported into OpenSCAD.</p>

<p>Update: This code does the same, and generates an html file with annotated images of the files rendered.  When I printed a batch of spare parts for my 3D printer I made a hardcopy and stuck it in the box so I could identify the parts later.</p>

<pre><code>n=-1
H=00-catalog.html
echo &gt;<span class="math-container">$H '&lt;table&gt;'
echo &gt;&gt;$</span>H '  &lt;tr&gt;'
for i in <span class="math-container">$*; do
  n=`expr $</span>n + 1`
  if test $n = 4; then
      n=0
      echo &gt;&gt;$H '  &lt;/tr&gt;'
      echo &gt;&gt;$H '  &lt;tr&gt;'
  fi
  echo $i
  T=__tmp__$i
  B=`basename <span class="math-container">$i .stl`
  echo import\(\"$</span>i\"\)\; &gt;<span class="math-container">$T
  /Applications/OpenSCAD.app//Contents/MacOS/OpenSCAD -o $</span>B.png --imgsize=200,200 <span class="math-container">$T
  echo &gt;&gt;$</span>H
  echo &gt;&gt;<span class="math-container">$H '    &lt;td&gt;'$</span>i'&lt;br&gt;&lt;img src="'$B'.png"&gt;&lt;/td&gt;'

  rm <span class="math-container">$T
done
echo &gt;&gt;$</span>H '  &lt;/tr&gt;'
echo &gt;&gt;$H '&lt;/table&gt;'
</code></pre>

CC BY-SA 4.0
2021-11-04T18:14:27.453Z
I've been trying to understand this code for a long time. What does the `echo import\(\"./$i\"\)\; > "$T"` line actually do? I'm trying to edit it so I can convert files that contain spaces in their names.
erdostamasa
CC BY-SA 4.0
2021-12-20T05:57:38.577Z
Note: If using in a headless environment like CI/CD/Github Actions, you will need an x11 environment. A workaround is to start a fake X11 with Xvfb e.g ( `Xvfb :99 & export DISPLAY=:99`)
spuder
CC BY-SA 4.0
2022-09-11T16:49:27.500Z
@erdostamasa - the line is creating a one line temporary script that does an import of the STL file. When openscad is called, it imports this file then the `-o` and `--imgsize=100,100` from the command line do the rest. The `rm $T` then cleans up this temporary file.
Ken Hiatt
CC BY-SA 4.0
2018-05-28T07:11:30.883Z
2019-01-09T19:17:38.013Z
2019-01-09T19:17:38.013Z
Mark Harrison
<p>I need to add some simple image renders of STL files to a document.  I currently open the STL files in Preview or one of the slicers and grab a screen shot.</p>

<p>Is there an easier or automatic way to generate PNG images from STL files on a Mac?</p>

CC BY-SA 4.0
2018-05-30T02:31:52.823Z
The answer below sounds pretty good, so I'll just comment that Google turns up a number of options for generating *postscript* files from STL, and you should be able to convert those to other image formats.  I'm not sure how lossy that transition would be (and it'll vary by tool), but figured I'd mention it in case someone comes here looking for e.g. a non-Mac solution...
A C
<slicing><stl>
How can I create PNG image files from STL files?
Mark Harrison
# How can I create PNG image files from STL files?

(Asked by: username_0 on 2018-05-28)

I need to add some simple image renders of STL files to a document. I currently open the STL files in Preview or one of the slicers and grab a screen shot.

Is there an easier or automatic way to generate PNG images from STL files on a Mac?

**Tags:** slicing, stl
> **Comments:**
> **username_1**: The answer below sounds pretty good, so I'll just comment that Google turns up a number of options for generating *postscript* files from STL, and you should be able to convert those to other image formats.  I'm not sure how lossy that transition would be (and it'll vary by tool), but figured I'd mention it in case someone comes here looking for e.g. a non-Mac solution...  

---

## 4 answers

### Answer by username_0 on 2018-05-28. Score: 12 | Accepted answer

If you have OpenSCAD installed, this shell script will generate 100x100 pixel PNG images for each STL file in your current directory.
for i in *.stl; do
  T=__tmp__$i
  b=`basename $i`
  echo import\(\"$i\"\)\; >$T
  /Applications/OpenSCAD.app/Contents/MacOS/OpenSCAD -o $b.png --imgsize=100,100 $T
  rm $T
done

Credit to 0scar for pointing out STL files can be imported into OpenSCAD.
Update: This code does the same, and generates an html file with annotated images of the files rendered.  When I printed a batch of spare parts for my 3D printer I made a hardcopy and stuck it in the box so I could identify the parts later.
n=-1
H=00-catalog.html
echo >$H ''
echo >>$H '  '
for i in $*; do
  n=`expr $n + 1`
  if test $n = 4; then
      n=0
      echo >>$H '  '
      echo >>$H '  '
  fi
  echo $i
  T=__tmp__$i
  B=`basename $i .stl`
  echo import\(\"$i\"\)\; >$T
  /Applications/OpenSCAD.app//Contents/MacOS/OpenSCAD -o $B.png --imgsize=200,200 $T
  echo >>$H
  echo >>$H '    '$i''

  rm $T
done
echo >>$H '  '
echo >>$H ''

> **Comments:**
> **username_6**: I've been trying to understand this code for a long time. What does the `echo import\(\"./$i\"\)\; > "$T"` line actually do? I'm trying to edit it so I can convert files that contain spaces in their names.  
> **username_7**: Note: If using in a headless environment like CI/CD/Github Actions, you will need an x11 environment. A workaround is to start a fake X11 with Xvfb e.g ( `Xvfb :99 & export DISPLAY=:99`)  
> **username_8**: @erdostamasa - the line is creating a one line temporary script that does an import of the STL file. When openscad is called, it imports this file then the `-o` and `--imgsize=100,100` from the command line do the rest. The `rm $T` then cleans up this temporary file.  

---

### Answer by username_2 on 2018-05-28. Score: 4

Typically you would install a (free) 3D model program as Fusion 360, FreeCAD, or many more options to choose from. Once installed, import the STL file and use menu options to export a picture of your STL.
Alternatively, if you have some programming skills, you could import the STL file in OpenSCAD and render and export a picture from there. Simply create an OpenSCAD file with the code line below and it will import your example.stl. 
import("example.stl", convexity=10);

Through the menu you can then export the view to an image. Note that you can do that also from the command line as shown by the OP's own answer (nice example of command line usage of OpenSCAD).
These are not the only options, there are many more. E.g. this is a nice example. It also describes how Thingiverse.com does STL to web image.

> **Comments:**
> **username_3**: For those looking for a nautilus thumbnailer using this technique, I've written a quick one here: https://github.com/sbrl/nautilus-thumbnailer-stl/  

---

### Answer by username_4 on 2018-05-28. Score: 2

If you don't mind using screen grabs, you could use AppleScript or whatever it's called in the latest MacOS versions to build an automated script to open each file, grab screen, save, etc.


---

### Answer by username_5 on 2019-08-14. Score: 1

You can use OpenSCAD, as stated in the accepted answer. 
Here is a version of that script that works for Windows for anyone who needs it, as I did.
# Change height and width to the desired output image dimensions, in pixels.
# The path to openscad.exe may also have to be adjusted based on your installation.

height=1080
width=1080

for i in *.stl; do
  T=__tmp__$i
  b=`basename "$i"`
  echo import\(\"./$i\"\)\; > "$T"
  C:/'Program Files'/OpenSCAD/openscad.exe -o "$b".png --autocenter --viewall --imgsize=$width,$height "$T"
  rm "$T"
done

> **Comments:**
> **username_6**: What does the `echo import\(\"./$i\"\)\; > "$T"` line do? I'm trying to convert files with spaces in their names but keep getting various errors.  

---

