<p>Netfabb came up in a number of suggestions that I found. Take a look at <a href="https://www.unixmen.com/3d-printing-arch-linux/" rel="nofollow noreferrer">3D Printing Under Arch Linux</a>, which offers a number of solutions for Linux, including:</p>

<ul>
<li>OpenSCAD</li>
<li>FreeCAD</li>
<li>Blender</li>
<li>NetFabb</li>
<li>Slic3r</li>
</ul>

<h3>Netfabb</h3>

<p>Taking the section on Netfabb:</p>

<blockquote>
  <p>netfabb Private will provide you with a fully-loaded tool-box to do all this and much more:</p>
  
  <ul>
  <li>fix complicated file errors</li>
  <li>make late design changes</li>
  <li>combine parts into one</li>
  <li>hollow out solid parts into a shell</li>
  <li>smooth the mesh to improve surfaces</li>
  <li><strong>reduce file size</strong></li>
  </ul>
</blockquote>

<p>Installing it:</p>

<blockquote>
  <p>netfabb is not at official repository so you must install it from AUR
  using yaourt</p>

<pre><code>$ yaourt netfabb-basic
$ netfabb-basic
</code></pre>
</blockquote>

<p>However, it is unclear as to whether there is a cmd line interface. It could be worth reading <a href="https://forums.autodesk.com/t5/installation-licensing/problem-in-netfabb-command-line-execution/td-p/7270370" rel="nofollow noreferrer">Problem in Netfabb Command Line execution</a> and <em>in particular</em> the documentation on <a href="http://help.autodesk.com/view/NETF/2018/ENU/?guid=GUID-596074CF-01B2-4F5F-A758-AD0A45BC02D3" rel="nofollow noreferrer">Automating Netfabb</a> - although this seems to suggest that command line functionality is only available to users with <em>Ultimate</em> subscription and not <em>Basic</em>:</p>

<blockquote>
  <p><a href="https://i.sstatic.net/yFefA.png" rel="nofollow noreferrer" title="Automating Netfabb"><img src="https://i.sstatic.net/yFefA.png" alt="Automating Netfabb" title="Automating Netfabb"></a></p>
</blockquote>

<p>From <a href="https://www.shapeways.com/forum/t/reducing-size-of-stl-file-to-upload-to-shapeways.24807/" rel="nofollow noreferrer">Reducing Size of STL file to upload to shapeways</a>, <a href="https://www.shapeways.com/forum/t/reducing-size-of-stl-file-to-upload-to-shapeways.24807/#post-109160" rel="nofollow noreferrer">this post (#10)</a> states:</p>

<blockquote>
  <p>You can also decimate the model in Netfabb easily - Right click > Level of Detail > Choose something like 50%... or more or less depending on the level of detail needed.</p>
</blockquote>

<p>Although, this isn't available in Basic subscription, or so says <a href="https://www.shapeways.com/forum/t/reducing-size-of-stl-file-to-upload-to-shapeways.24807/#post-109166" rel="nofollow noreferrer">post #12</a>.</p>

<hr>

<h3>Meshmixer</h3>

<p>I also came across this, non-command line option.</p>

<p>From <a href="https://i.materialise.com/blog/en/reduce-the-file-size-of-stl-and-obj-3d-models/" rel="nofollow noreferrer">How to Reduce the File Size of .STL and .OBJ 3D Models</a></p>

<blockquote>
  <p>For example, you can give the free 3D modeling program <a href="http://www.meshmixer.com" rel="nofollow noreferrer">Meshmixer</a> a try. Choose the ‘Select’ tool from the menu on the right, then double-click on your model (this will select your entire mesh). Then click on the ‘Edit…’ option and select ‘Reduce’.</p>
  
  <p>You can now reduce the polygon count using several options. The best working choice is to use the percentage tool. It will immediately tell you by how much percent your file size (and polygon count) has been reduced.</p>
</blockquote>

<p>Available for Windows and OSX.</p>

<p>From <a href="https://www.shapeways.com/forum/t/reducing-size-of-stl-file-to-upload-to-shapeways.24807/" rel="nofollow noreferrer">Reducing Size of STL file to upload to shapeways</a>, <a href="https://www.shapeways.com/forum/t/reducing-size-of-stl-file-to-upload-to-shapeways.24807/#post-109087" rel="nofollow noreferrer">this post (#8)</a> states:</p>

<blockquote>
  <p>The <a href="https://www.shapeways.com/tutorials/polygon_reduction_with_meshlab" rel="nofollow noreferrer">meshlab tutorial</a> is exactly what you want to do - the options described help preserve the overall geometry of the model while reducing the poly count. Start with a target of 150,000 polys and work up until the desired detail is retained, bearing in mind the printability I mentioned above.</p>
</blockquote>

<p>Also, by way of Quora, <a href="https://www.quora.com/How-do-I-reduce-the-size-of-an-STL-file-Does-it-affect-the-CAD-coordinates-for-3D-printing" rel="nofollow noreferrer">How do I reduce the size of an STL file? Does it affect the CAD coordinates for 3D printing?</a>, I also found this Meshmixer tutorial: <a href="https://pinshape.com/blog/how-to-repair-your-stl-files/" rel="nofollow noreferrer">Easy Guide on How to Repair Your .STL Files</a>. Under the section <strong>Problem 4: File Size is too Large for 3D Printing</strong> are the following steps:</p>

<blockquote>
  <p>The last problem that you may stumble upon, particularly as your
  objects get larger and their complexity increases, is that the
  resulting <code>.stl</code> file size is too large for your 3D printer or 3D
  printing service of choice. Third party printing services like
  <a href="https://i.materialise.com/" rel="nofollow noreferrer">i.materialise</a> or <a href="http://www.shapeways.com/" rel="nofollow noreferrer">Shapeways</a>  have upload limits so you may have to
  change the size of your file (100&nbsp;MB limit at imaterialise and 64&nbsp;MB for
  Shapeways). It’s important to reduce the mesh without sacrificing the
  quality, which I should say at the outset is best done at the initial
  export from your CAD software to minimise any distortion. My number one quick
  tip is to make sure in the export settings that your saving in
  ‘Binary’ format, not ‘ASCII’ –  it’s a significantly more compact file
  format for <code>.stl</code>’s without losing quality). However if it’s not an
  option, Meshmixer can be really useful to quickly reduce file size and
  visualise how this will affect the quality of your surfaces.</p>
  
  <p>For this example I’m going to return to the leaf from Problem 1, which
  as a <code>.stl</code> file is 30.757&nbsp;MB – pretty large for such a small design and
  definitely over the limit for someone’s email if I wanted to send it.
  So let’s look at how we can get this under 10&nbsp;MB.</p>
  
  <ol>
  <li>Select the entire model by pressing Ctrl + A on your keyboard to select all.</li>
  <li>Go to <strong>Edit>Reduce</strong> to bring up the options to reduce the mesh. Essentially the file size of a <code>.stl</code> is directly related to the number
  of polygons (triangles) that make up all of the surfaces. We will use
  the Reduce tool to reduce the quantity of polygons, therefore reducing
  file size.</li>
  <li>The menu will give you a range of options to reduce the size of your file. The simplest is to use the default Percentage option,
  allowing you to determine the final file size you want rather than
  needing to know exactly how many triangles will be used to make up the
  file. In this case I have calculated that in order to get my original
  .stl file below 10&nbsp;MB, I need a reduction of 70&nbsp;% or more. As you
  adjust the values, you will get a preview of what your model will look
  like, allowing you to control how much reduction you employ before the
  model becomes too distorted and ‘pixelated.’</li>
  </ol>
  
  <p><a href="https://i.sstatic.net/bGp8F.png" rel="nofollow noreferrer" title="Reduce dialog"><img src="https://i.sstatic.net/bGp8F.png" alt="Reduce dialog" title="Reduce dialog"></a></p>
  
  <ol start="4">
  <li>Once you’re happy and have accepted the changes, you can click on the Export button or go to <strong>File>Export</strong> to save this new reduced <code>.stl</code>
  file. As you can see in the comparison below, there is almost no
  perceptible difference in the quality of the 30.757&nbsp;MB file compared
  with the final reduced version at 9.362&nbsp;MB. I have simply increased the
  size of the triangles, minimising the quantity needed to create the
  same volume. Your regular 3D printer, or even a highly accurate SLS
  printer will never even know the difference in a change like this.
  It’s only if you really go crazy with the file reduction that you
  might start to notice them in your final print (and in fact many of
  the low-poly models which are popular on Pinshape can be produced
  using this technique – start with a detailed .stl of the object you
  want, and then just keep reducing the number of triangles!).</li>
  </ol>
  
  <p><a href="https://i.sstatic.net/fzPYw.png" rel="nofollow noreferrer" title="Reduction of file size"><img src="https://i.sstatic.net/fzPYw.png" alt="Reduction of file size" title="Reduction of file size"></a></p>
</blockquote>

<h3>Blender</h3>

<p>From <a href="https://www.shapeways.com/forum/t/reducing-size-of-stl-file-to-upload-to-shapeways.24807/" rel="nofollow noreferrer">Reducing Size of STL file to upload to shapeways</a>, <a href="https://www.shapeways.com/forum/t/reducing-size-of-stl-file-to-upload-to-shapeways.24807/#post-109087" rel="nofollow noreferrer">this post (#8)</a> states:</p>

<blockquote>
  <p>Another option is to import the model into Blender, then use the Remesh or Decimate modifiers. Blender can be tough to get into initially but there are plenty of introduction tutorials on YouTube to help.</p>
</blockquote>

<p>Blender <em>does</em> offer a Command Line Interface (CLI), see <a href="https://docs.blender.org/manual/en/dev/advanced/command_line/arguments.html#command-line-arguments" rel="nofollow noreferrer">Command Line Arguments</a>:</p>

<pre><code>Usage: blender [args …] [file] [args …]
</code></pre>

<p>However, there doesn't appear to be an option for <em>Remesh</em> or <em>Decimate</em>. Although take a look at <a href="https://blender.stackexchange.com/questions/115069/is-it-possible-to-decimate-or-remesh-via-the-cli">Is it possible to decimate or remesh via the CLI?</a>:</p>

<blockquote>
  <p>You can specify a Python script to run, see the <a href="https://docs.blender.org/manual/en/dev/advanced/command_line/arguments.html#python-options" rel="nofollow noreferrer">Python Options</a> section of <a href="https://docs.blender.org/manual/en/dev/advanced/command_line/arguments.html" rel="nofollow noreferrer">the documentation</a> you linked. In this script, you can import the model, add the modifiers, apply them and export the result. </p>
</blockquote>

<p>Related - <a href="https://blender.stackexchange.com/questions/474/is-it-possible-to-automatically-simplify-geometry-in-blender-without-losing-obje">Is it possible to automatically simplify geometry in blender without losing object shape?</a>, which has <a href="https://blender.stackexchange.com/questions/474/is-it-possible-to-automatically-simplify-geometry-in-blender-without-losing-obje#comment33919_475">this comment</a>:</p>

<blockquote>
  <p>Is there a way to execute this modifier from command line and export the result? </p>
</blockquote>

<p>which then leads to <a href="https://blender.stackexchange.com/questions/2876/can-modifiers-be-computed-and-applied-from-the-command-line">Can modifiers be computed and applied from the command line?</a></p>

<blockquote>
  <p>You'd have to use <a href="http://www.blender.org/documentation/blender_python_api_2_68_2/bpy.ops.object.html#bpy.ops.object.modifier_apply" rel="nofollow noreferrer"><code>bpy.ops.object.modifier_apply</code></a>, e.g.</p>

<pre><code>import bpy

for obj in bpy.context.scene.objects:
    bpy.context.scene.objects.active = obj
    count = 1
    length = len(obj.modifiers)
    while obj.modifiers:
        name = obj.modifiers[0].name
        print("%s: Applying %s (%d/%d)" % (obj, name, count, length))
        bpy.ops.object.modifier_apply(modifier=name)
        count += 1
print("All done.")
</code></pre>
  
  <p><em>For info on how to to run the above, <a href="https://blender.stackexchange.com/q/1365/290">see here</a>.</em></p>
</blockquote>

<h3>Meshlab</h3>

<p>Seeing as you are already using Meshlab, it might be worth reading <a href="https://gist.github.com/awesomebytes/a3bc8729d0c1d0a9499172b9a77d2622" rel="nofollow noreferrer">Executing meshlab from commandline reduce faces of a mesh iteratively</a> (awesomebytes/<a href="https://gist.github.com/awesomebytes/a3bc8729d0c1d0a9499172b9a77d2622" rel="nofollow noreferrer">reduce_faces.py</a>)</p>

<pre><code>#!/usr/bin/env python

import sys
import os
import subprocess

# Script taken from doing the needed operation
# (Filters &gt; Remeshing, Simplification and Reconstruction &gt;
# Quadric Edge Collapse Decimation, with parameters:
# 0.9 percentage reduction (10%), 0.3 Quality threshold (70%)
# Target number of faces is ignored with those parameters
# conserving face normals, planar simplification and
# post-simplimfication cleaning)
# And going to Filter &gt; Show current filter script
filter_script_mlx = """&lt;!DOCTYPE FilterScript&gt;
&lt;FilterScript&gt;
 &lt;filter name="Quadric Edge Collapse Decimation"&gt;
  &lt;Param type="RichInt" value="1448" name="TargetFaceNum"/&gt;
  &lt;Param type="RichFloat" value="0.9" name="TargetPerc"/&gt;
  &lt;Param type="RichFloat" value="0.3" name="QualityThr"/&gt;
  &lt;Param type="RichBool" value="false" name="PreserveBoundary"/&gt;
  &lt;Param type="RichFloat" value="1" name="BoundaryWeight"/&gt;
  &lt;Param type="RichBool" value="true" name="PreserveNormal"/&gt;
  &lt;Param type="RichBool" value="false" name="PreserveTopology"/&gt;
  &lt;Param type="RichBool" value="false" name="OptimalPlacement"/&gt;
  &lt;Param type="RichBool" value="true" name="PlanarQuadric"/&gt;
  &lt;Param type="RichBool" value="false" name="QualityWeight"/&gt;
  &lt;Param type="RichBool" value="true" name="AutoClean"/&gt;
  &lt;Param type="RichBool" value="false" name="Selected"/&gt;
 &lt;/filter&gt;
&lt;/FilterScript&gt;
"""


def create_tmp_filter_file(filename='filter_file_tmp.mlx'):
    with open('/tmp/' + filename, 'w') as f:
        f.write(filter_script_mlx)
    return '/tmp/' + filename


def reduce_faces(in_file, out_file,
                 filter_script_path=create_tmp_filter_file()):
    # Add input mesh
    command = "meshlabserver -i " + in_file
    # Add the filter script
    command += " -s " + filter_script_path
    # Add the output filename and output flags
    command += " -o " + out_file + " -om vn fn"
    # Execute command
    print "Going to execute: " + command
    output = subprocess.check_output(command, shell=True)
    last_line = output.splitlines()[-1]
    print
    print "Done:"
    print in_file + " &gt; " + out_file + ": " + last_line


if __name__ == '__main__':
    if len(sys.argv) &lt; 3:
        print "Usage:"
        print sys.argv[0] + " /path/to/input_mesh num_iterations"
        print "For example, reduce 10 times:"
        print sys.argv[0] + " /home/myuser/mymesh.dae 10"
        exit(0)

    in_mesh = sys.argv[1]
    filename = in_mesh.split('/')[-1]
    num_iterations = int(sys.argv[2])

    folder_name = filename.replace('.', '_')
    tmp_folder_name = '/tmp/' + folder_name + '_meshes/'

    print "Input mesh: " + in_mesh + " (filename: " + filename + ")"
    print "Num iterations: " + str(num_iterations)
    print "Output folder: " + tmp_folder_name
    try:
        os.mkdir(tmp_folder_name)
    except OSError as e:
        print &gt;&gt; sys.stderr, "Exception creating folder for meshes: " + str(e)
        exit(0)
    for it in range(1, num_iterations):
        if it == 1:
            out_mesh = tmp_folder_name + folder_name + "_it" + str(it) + ".dae"
            reduce_faces(in_mesh, out_mesh)
        else:
            out_mesh = tmp_folder_name + folder_name + "_it" + str(it) + ".dae"
            reduce_faces(last_out_mesh, out_mesh)
        last_out_mesh = out_mesh

    print
print "Done reducing, find the files at: " + tmp_folder_name
</code></pre>

<p>Also</p>

<blockquote>
  <p>here are some updates for python 3.6.2: <a href="https://gist.github.com/tylerlindell/7435ca2261e7c404ccc1241f18e483aa" rel="nofollow noreferrer">https://gist.github.com/tylerlindell/7435ca2261e7c404ccc1241f18e483aa</a></p>
</blockquote>

CC BY-SA 4.0
2018-07-30T08:19:24.827Z
That's useful thanks! I'll just add that I've subsequently discovered that Meshlab has a `meshlab-server` CLI tool installed with the GUI tool. I haven't tested it yet, but in theory it should be as simple as figuring out the commandline syntax/command to invoke something like quadratic decimation etc.
Joe Healey
CC BY-SA 4.0
2018-07-30T11:27:04.383Z
Ah, well done @JoeHealey , that is excellent. Maybe you could post an answer, once you have figured it out? It would probably help others with the same issue. I would be interested in such a solution myself.
Greenonline
CC BY-SA 4.0
2018-07-30T11:36:39.560Z
I certainly will do. I've had to put the printing on the back burner for the moment while I finish writing my thesis but I intend to return to it when I have some more free time :)
Joe Healey
CC BY-SA 4.0
2018-07-30T02:54:11.850Z
2018-07-30T21:17:29.810Z
2018-07-30T21:17:29.810Z
Greenonline
<p>I'm facing the same problem 6 years later, Meshlab is running out of memory during <em>Quadratic Edge Collapse Decimation</em>.</p>
<p>There's another command line tool written in Go [1], which simplifies meshes in STL files.</p>
<p>The instructions that follow are for Linux (Debian).</p>
<p>First, make sure Go is installed on your system. Then install <code>simplify</code> with:</p>
<pre><code>go install  github.com/fogleman/simplify/cmd/simplify@latest
</code></pre>
<p>This will install to <code>~/go/bin/simplify</code>. Now simplify your mesh with:</p>
<pre><code># Reduce mesh to 10% of original size.
~/go/bin/simplify -f 0.1 input.stl output.stl
</code></pre>
<p>If you need to convert your 3D model to STL first, take a look at <code>openctm-tools</code> [2].</p>
<pre><code># Install OpenCTM tools.
sudo apt install openctm-tools

# Convert PLY to STL.
ctmconv intput.ply output.stl
</code></pre>
<p>[1] <a href="https://github.com/fogleman/simplify" rel="nofollow noreferrer">https://github.com/fogleman/simplify</a></p>
<p>[2] <a href="https://openctm.sourceforge.net/" rel="nofollow noreferrer">https://openctm.sourceforge.net/</a></p>

CC BY-SA 4.0
2024-03-14T11:03:29.743Z
Thanks for digging this up and posting a more recent solution. Much appreciated! Welcome to 3DPrinting.SE!
0scar
CC BY-SA 4.0
2024-03-14T08:59:16.573Z
2024-03-14T08:59:16.573Z
sebastian
<p>I'm currently trying to remesh and simplify some protein structure models (very large) to reduce the file size of the STLs I need to print from.</p>

<p>The raw file before manipulation is ~4.9GB.</p>

<p>I'm currently attempting this on my home PC (16GB Ram, AMD FX9590, dual RX480s - so no slouch by any stretch) but I'm currently watching the progress (which isn't fast), and the RAM usage is worryingly close to 16GB now, with about 40% of the calculation still to go.</p>

<p>I'm using MeshLab's Quadratic Edge Collapse Decimation, to drop down by about 60% since there are a lot of redundance internal vertices etc and the print will already be quite difficult even with a small number of faces.</p>

<p>If my PC ends up not being able to handle this, does anyone know of any good commandline tools for Unix that I could use on one of my servers to handle remeshing and simplification, where I have considerably more ram and CPU power available.</p>

<p>First post on this SE, so apologies if this belongs somewhere different.</p>

<print-quality><3d-models><software><slicing>
commandline remeshing and simplifying tools
Joe Healey
# commandline remeshing and simplifying tools

(Asked by: username_0 on 2017-09-23)

I'm currently trying to remesh and simplify some protein structure models (very large) to reduce the file size of the STLs I need to print from.

The raw file before manipulation is ~4.9GB.

I'm currently attempting this on my home PC (16GB Ram, AMD FX9590, dual RX480s - so no slouch by any stretch) but I'm currently watching the progress (which isn't fast), and the RAM usage is worryingly close to 16GB now, with about 40% of the calculation still to go.

I'm using MeshLab's Quadratic Edge Collapse Decimation, to drop down by about 60% since there are a lot of redundance internal vertices etc and the print will already be quite difficult even with a small number of faces.

If my PC ends up not being able to handle this, does anyone know of any good commandline tools for Unix that I could use on one of my servers to handle remeshing and simplification, where I have considerably more ram and CPU power available.

First post on this SE, so apologies if this belongs somewhere different.

**Tags:** print-quality, 3d-models, software, slicing

---

## 2 answers

### Answer by username_1 on 2018-07-30. Score: 7

Netfabb came up in a number of suggestions that I found. Take a look at 3D Printing Under Arch Linux, which offers a number of solutions for Linux, including:

OpenSCAD
FreeCAD
Blender
NetFabb
Slic3r

Netfabb
Taking the section on Netfabb:

netfabb Private will provide you with a fully-loaded tool-box to do all this and much more:

fix complicated file errors
make late design changes
combine parts into one
hollow out solid parts into a shell
smooth the mesh to improve surfaces
reduce file size


Installing it:

netfabb is not at official repository so you must install it from AUR
  using yaourt
$ yaourt netfabb-basic
$ netfabb-basic


However, it is unclear as to whether there is a cmd line interface. It could be worth reading Problem in Netfabb Command Line execution and in particular the documentation on Automating Netfabb - although this seems to suggest that command line functionality is only available to users with Ultimate subscription and not Basic:



From Reducing Size of STL file to upload to shapeways, this post (#10) states:

You can also decimate the model in Netfabb easily - Right click > Level of Detail > Choose something like 50%... or more or less depending on the level of detail needed.

Although, this isn't available in Basic subscription, or so says post #12.

Meshmixer
I also came across this, non-command line option.
From How to Reduce the File Size of .STL and .OBJ 3D Models

For example, you can give the free 3D modeling program Meshmixer a try. Choose the ‘Select’ tool from the menu on the right, then double-click on your model (this will select your entire mesh). Then click on the ‘Edit…’ option and select ‘Reduce’.
You can now reduce the polygon count using several options. The best working choice is to use the percentage tool. It will immediately tell you by how much percent your file size (and polygon count) has been reduced.

Available for Windows and OSX.
From Reducing Size of STL file to upload to shapeways, this post (#8) states:

The meshlab tutorial is exactly what you want to do - the options described help preserve the overall geometry of the model while reducing the poly count. Start with a target of 150,000 polys and work up until the desired detail is retained, bearing in mind the printability I mentioned above.

Also, by way of Quora, How do I reduce the size of an STL file? Does it affect the CAD coordinates for 3D printing?, I also found this Meshmixer tutorial: Easy Guide on How to Repair Your .STL Files. Under the section Problem 4: File Size is too Large for 3D Printing are the following steps:

The last problem that you may stumble upon, particularly as your
  objects get larger and their complexity increases, is that the
  resulting .stl file size is too large for your 3D printer or 3D
  printing service of choice. Third party printing services like
  i.materialise or Shapeways  have upload limits so you may have to
  change the size of your file (100 MB limit at imaterialise and 64 MB for
  Shapeways). It’s important to reduce the mesh without sacrificing the
  quality, which I should say at the outset is best done at the initial
  export from your CAD software to minimise any distortion. My number one quick
  tip is to make sure in the export settings that your saving in
  ‘Binary’ format, not ‘ASCII’ –  it’s a significantly more compact file
  format for .stl’s without losing quality). However if it’s not an
  option, Meshmixer can be really useful to quickly reduce file size and
  visualise how this will affect the quality of your surfaces.
For this example I’m going to return to the leaf from Problem 1, which
  as a .stl file is 30.757 MB – pretty large for such a small design and
  definitely over the limit for someone’s email if I wanted to send it.
  So let’s look at how we can get this under 10 MB.

Select the entire model by pressing Ctrl + A on your keyboard to select all.
Go to Edit>Reduce to bring up the options to reduce the mesh. Essentially the file size of a .stl is directly related to the number
  of polygons (triangles) that make up all of the surfaces. We will use
  the Reduce tool to reduce the quantity of polygons, therefore reducing
  file size.
The menu will give you a range of options to reduce the size of your file. The simplest is to use the default Percentage option,
  allowing you to determine the final file size you want rather than
  needing to know exactly how many triangles will be used to make up the
  file. In this case I have calculated that in order to get my original
  .stl file below 10 MB, I need a reduction of 70 % or more. As you
  adjust the values, you will get a preview of what your model will look
  like, allowing you to control how much reduction you employ before the
  model becomes too distorted and ‘pixelated.’



Once you’re happy and have accepted the changes, you can click on the Export button or go to File>Export to save this new reduced .stl
  file. As you can see in the comparison below, there is almost no
  perceptible difference in the quality of the 30.757 MB file compared
  with the final reduced version at 9.362 MB. I have simply increased the
  size of the triangles, minimising the quantity needed to create the
  same volume. Your regular 3D printer, or even a highly accurate SLS
  printer will never even know the difference in a change like this.
  It’s only if you really go crazy with the file reduction that you
  might start to notice them in your final print (and in fact many of
  the low-poly models which are popular on Pinshape can be produced
  using this technique – start with a detailed .stl of the object you
  want, and then just keep reducing the number of triangles!).



Blender
From Reducing Size of STL file to upload to shapeways, this post (#8) states:

Another option is to import the model into Blender, then use the Remesh or Decimate modifiers. Blender can be tough to get into initially but there are plenty of introduction tutorials on YouTube to help.

Blender does offer a Command Line Interface (CLI), see Command Line Arguments:
Usage: blender [args …] [file] [args …]

However, there doesn't appear to be an option for Remesh or Decimate. Although take a look at Is it possible to decimate or remesh via the CLI?:

You can specify a Python script to run, see the Python Options section of the documentation you linked. In this script, you can import the model, add the modifiers, apply them and export the result. 

Related - Is it possible to automatically simplify geometry in blender without losing object shape?, which has this comment:

Is there a way to execute this modifier from command line and export the result? 

which then leads to Can modifiers be computed and applied from the command line?

You'd have to use bpy.ops.object.modifier_apply, e.g.
import bpy

for obj in bpy.context.scene.objects:
    bpy.context.scene.objects.active = obj
    count = 1
    length = len(obj.modifiers)
    while obj.modifiers:
        name = obj.modifiers[0].name
        print("%s: Applying %s (%d/%d)" % (obj, name, count, length))
        bpy.ops.object.modifier_apply(modifier=name)
        count += 1
print("All done.")

For info on how to to run the above, see here.

Meshlab
Seeing as you are already using Meshlab, it might be worth reading Executing meshlab from commandline reduce faces of a mesh iteratively (awesomebytes/reduce_faces.py)
#!/usr/bin/env python

import sys
import os
import subprocess

# Script taken from doing the needed operation
# (Filters > Remeshing, Simplification and Reconstruction >
# Quadric Edge Collapse Decimation, with parameters:
# 0.9 percentage reduction (10%), 0.3 Quality threshold (70%)
# Target number of faces is ignored with those parameters
# conserving face normals, planar simplification and
# post-simplimfication cleaning)
# And going to Filter > Show current filter script
filter_script_mlx = """

 
  
  
  
  
  
  
  
  
  
  
  
  
 

"""


def create_tmp_filter_file(filename='filter_file_tmp.mlx'):
    with open('/tmp/' + filename, 'w') as f:
        f.write(filter_script_mlx)
    return '/tmp/' + filename


def reduce_faces(in_file, out_file,
                 filter_script_path=create_tmp_filter_file()):
    # Add input mesh
    command = "meshlabserver -i " + in_file
    # Add the filter script
    command += " -s " + filter_script_path
    # Add the output filename and output flags
    command += " -o " + out_file + " -om vn fn"
    # Execute command
    print "Going to execute: " + command
    output = subprocess.check_output(command, shell=True)
    last_line = output.splitlines()[-1]
    print
    print "Done:"
    print in_file + " > " + out_file + ": " + last_line


if __name__ == '__main__':
    if len(sys.argv) < 3:
        print "Usage:"
        print sys.argv[0] + " /path/to/input_mesh num_iterations"
        print "For example, reduce 10 times:"
        print sys.argv[0] + " /home/myuser/mymesh.dae 10"
        exit(0)

    in_mesh = sys.argv[1]
    filename = in_mesh.split('/')[-1]
    num_iterations = int(sys.argv[2])

    folder_name = filename.replace('.', '_')
    tmp_folder_name = '/tmp/' + folder_name + '_meshes/'

    print "Input mesh: " + in_mesh + " (filename: " + filename + ")"
    print "Num iterations: " + str(num_iterations)
    print "Output folder: " + tmp_folder_name
    try:
        os.mkdir(tmp_folder_name)
    except OSError as e:
        print >> sys.stderr, "Exception creating folder for meshes: " + str(e)
        exit(0)
    for it in range(1, num_iterations):
        if it == 1:
            out_mesh = tmp_folder_name + folder_name + "_it" + str(it) + ".dae"
            reduce_faces(in_mesh, out_mesh)
        else:
            out_mesh = tmp_folder_name + folder_name + "_it" + str(it) + ".dae"
            reduce_faces(last_out_mesh, out_mesh)
        last_out_mesh = out_mesh

    print
print "Done reducing, find the files at: " + tmp_folder_name

Also

here are some updates for python 3.6.2: https://gist.github.com/tylerlindell/7435ca2261e7c404ccc1241f18e483aa

> **Comments:**
> **username_0**: That's useful thanks! I'll just add that I've subsequently discovered that Meshlab has a `meshlab-server` CLI tool installed with the GUI tool. I haven't tested it yet, but in theory it should be as simple as figuring out the commandline syntax/command to invoke something like quadratic decimation etc.  
> **username_1**: Ah, well done @JoeHealey , that is excellent. Maybe you could post an answer, once you have figured it out? It would probably help others with the same issue. I would be interested in such a solution myself.  
> **username_0**: I certainly will do. I've had to put the printing on the back burner for the moment while I finish writing my thesis but I intend to return to it when I have some more free time :)  

---

### Answer by username_2 on 2024-03-14. Score: 3

I'm facing the same problem 6 years later, Meshlab is running out of memory during Quadratic Edge Collapse Decimation.
There's another command line tool written in Go [1], which simplifies meshes in STL files.
The instructions that follow are for Linux (Debian).
First, make sure Go is installed on your system. Then install simplify with:
go install  github.com/fogleman/simplify/cmd/simplify@latest

This will install to ~/go/bin/simplify. Now simplify your mesh with:
# Reduce mesh to 10% of original size.
~/go/bin/simplify -f 0.1 input.stl output.stl

If you need to convert your 3D model to STL first, take a look at openctm-tools [2].
# Install OpenCTM tools.
sudo apt install openctm-tools

# Convert PLY to STL.
ctmconv intput.ply output.stl

[1] https://github.com/fogleman/simplify
[2] https://openctm.sourceforge.net/

> **Comments:**
> **username_3**: Thanks for digging this up and posting a more recent solution. Much appreciated! Welcome to 3DPrinting.SE!  

---

