2018/10/02
Reduce PNG sizes from Mac Finder
When I save a screenshot on my systems, it doesn’t try to automatically crush/minify the PNG. Here’s how on a Mac I’ve added a context menu item for images to crush them. This can help save storage space or make web pages load faster.
- Ensure you have pngquant installed. Other tools may work for you, but this post is pngquant-specific. I got it via Homebrew.
- Open Automator.
- Choose Service.
- In the Service Receives drop-down, select image files.
- In the left pane, select Utilities under Library.
- From the middle pane, drag Run Shell Script to the right pane.
- On the top of the box that was just created, use /bin/bash as the shell and pass input as arguments.
- Paste in the following code for the shell script:
123456for f in "$@"; dopngquant --nofs "$f"base="${f%.*}"ext="${base:+${f#$base}}"touch -r "$f" "$base-or8$ext"done - Choose a name to save the script as which is how you’d like to see in when right-clicking to get the context menu. I named mine png_crush.
Now when you right-click a PNG in Finder, go to Services, and click on the entry for png_crush. Works for multiple-selected files as well.
Reduce PNG sizes from Mac Finder is original content from devolve.