Tabletop Simulator

Tabletop Simulator

Not enough ratings
How to compress your bloated PNGs to reduce Workshop filesizes.
By Habanero
A lot of you are uploading games that have no business being as large as they are (16mb tokens, anyone?). Here's how to alleviate that.
2
   
Award
Favorite
Favorited
Unfavorite
Download OptiPng
Download it.[optipng.sourceforge.net] I don't see a macOS version, but Google says that you can install it with MacPorts or Brew. I'm on Windows. Extract the .exe to your working folder. OptiPng is a command line program, so for convenience you can use a simple batch script, or a GUI such as WOptiPNG[github.com]. For general users, the GUI is recommended, although it won't give you as precise of control as using the CLI. The GUI will let you adjust the number of CPU threads, priority, output to a different folder instead of overwriting, adjust the optimization level (OptiPng will try to do this automatically, but you can experiment if you want to try squeezing out a few more MB -- the higher, the more optimized it'll be) and let you process recursive subdirectories.
Get your images.
If you're a mod author, put the PNGs that you want to compress into a working folder (such as where you extracted optipng.exe). If you're a mod subscriber looking to reduce the bloat on someone else's workshop mod, you'll want to use TTS Backup[www.nexusmods.com]. TTS Backup will let you download the assets, give you a filesize estimate of your downloaded files (go into options to enable it), and replace the images by uploading them to your own Steam cloud if you prefer instead of having a local copy (useful if you think a Workshop upload might get DMCA'd). You can also just run OptiPng on TTS' Mods\Images folder and indiscriminately compress every PNG TTS/TTS-Backup has downloaded (download all the assets with TTS Backup, compress, then use TTSB to backup the mod).

If you're using TTS Backup, right click on the mod and select Download to download all assets, or highlight any number of images on the right panel and click on Download Files. You now have a local copy of the assets to optimize in your \Documents\My Games\Tabletop Simulator\Mods\Images folder. This is also the folder where TTS will download assets if you play online with a Workshop mod that you don't already have downloaded. Note that the assets are all mixed together. You can use TTS Backup's Backup feature to export a .zip file of any Workshop mod with all necessary assets that have been downloaded.

Note: TTS Backup does not download the audio assets. For that, you'll have to use Bored Maude.[gitlab.com] Simply run it from the command line (bored-maude download) and it will grab the audio files to backup. It can also clean out your cache folder of anything that isn't being used by your installed Workshop files.
Process your images.
You now have a folder full of images ready to be compressed. For this guide, we'll be using Root Ultimate Collection as an example, which has 768mb of PNGs that are loaded when you play the game.


If you're using the GUI, load them all and set the output directory (not recommended to overwrite the original files in case the final image gets messed up somehow). If you have CPU to spare, you can adjust the settings in the top right to make it go faster or optimize it further.

If you're using the CLI, you'll probably want to use a batch method. A basic batch script would be:

@echo off FOR /R %%a IN (*.png) DO ( optipng.exe "%%a" -backup ) pause

If your OptiPng.exe is in another folder, add the filepath in front of optipng.exe (C:\Folder\optipng.exe or whatever). Save that as a .bat file and execute it in the same folder as the PNGs you want to compress. Note that the script is recursive (/R), and will also process any PNGs inside subfolders. The -backup argument will rename your original PNGs to .BAK after compression. I don't recommend overwriting the original files, but if you want to, change -backup to:
-out "%%a"

If you want to rename the compressed PNGs:
-out "%%~na OptiPng.png"
Change " OptiPng" to whatever.

After the optimization is done, let's check the filesize differences. If you're using the GUI, it'll tell you how much space you shaved off on the bottom right. It seems kinda bugged though and might not display the correct number sometimes.


We shaved off 253MB from the Root images, bring it down to 515MB from 768MB. Not a lot by itself, but that quickly adds up when you're downloading a few dozen mods (my mod backup folder was 17GB before compressing, which shaved 5GB off it). The largest image went from 25MB to 10MB with no noticeable visual differences.

https://screenshotcomparison.com/comparison/25655
If that site's hover doesn't work properly for some reason, here are the direct links to the images.
Before[files.catbox.moe]
After[files.catbox.moe]

You might be able to crunch more out of it by increasing the compression level ("optipng -h" on the CLI to see the options). Be sure to always compare the before and after of your processed images, in case optipng does something screwy with the final result. I haven't noticed any instances of colors, etc. being messed up, but you might as well be safe. Common victims of cmpression gone wrong are detailed things such as screentone, gradients, etc.

That about covers it. For just 10 minutes per upload, you, too, can help reduce bloat in the Workshop.
2 Comments
Qwazzy 16 Mar, 2024 @ 10:10pm 
Good guide. Granted, I didn't use it for TTS specifically - I made a basic PCIO package for PlayingCards.io using a card grid, and the sizes made the total end result about 250mb - so I extracted the end package and ran the images through this program. Wasn't a huge saving on size (about 8% less) but every little bit counts, especially when playing in a browser that has to download everything over cellular.
Nah 27 Sep, 2022 @ 2:11pm 
Is there an option to increase size for no noticeable visual difference?