PNG Optimizer

I see no noticeable difference between the optimized and not optimized when using

I don’t know what exactly Squash does. Judging by the reviews on the MAS and on macupdate, it doesn’t seem very promising.

Virtually all good PNG tools are open source or freeware, e.g. pngquant or advpng (which I’m both using in my macro).

Pngquant can reduce the size by a huge degree, but it is not lossless, since it reduces the number of colors. However you can set the amount of quantization by setting the desired percentage of the original quality, which is very handy. And for things like screenshots (large areas of uniform colors, not much halftones) 256 colors or less are more than enough.

Advpng is lossless and thus not as efficient as pngquant. It optimizes the PNG compression by applying more efficient algorithms.

A combination of both yields very good results which are hard to beat IMO.

I might just be stuck with bloating my Scrivener files because I need them inline with the text I am typing and see no other way around it.

If you need them inline, a couple of possibilities come to mind:

  • Produce HTML documents
  • Use Apple’s RTF implementation (aka TextEdit). If you add images to an Apple-RTF the document will be converted to .rtfd, which is a document bundle that contains the text (RTF) file and the unchanged images.
  • Use Ulysses
  • Use iA Writer
  • Use Nisus Writer
  • Use Quiver
1 Like

Thank you I have purchased DevonThink Pro and Papers but they were a bit more than what I needed in the end and just got in the way.

I actually have Quiver and considered it but it doesn't seem to add images inline but I will have to mess with that some more. Seems like I purchased Ulysses in a bundle but I will have to look for that if I really did or not.

Thanks for the help and tips.

I actually have Quiver and considered it but it doesn't seem to add images inline but I will have to mess with that some more.

Well, you can drag images into a Text cell. But, since the whole Quiver is based on cells, I think this qualifies as “inline” :wink:

I have purchased DevonThink Pro and Papers but they were a bit more than what I needed in the end and just got in the way.

If you’re looking for something like DevonThink that does not get in the way have a look at EagleFiler. There exists an entire thread about the “DevonThink aggravation”, and I’ve posted a short summary of EagleFiler there.

1 Like

Thank you Tom this is great and I look forward very much to using EagleFlier, I just read through the thread you posted to and look forward to trying out your macros you made for EagleFiler. Always great to learn and know others tried and experienced the same pain I felt when using DevonThink Pro. I just kept thinking I need to give it a better chance and spend more time with it but the non integration with the Finder really was the show stopper and made me wonder why I even purchased in the first place at the extreme cost.

Hi skillet,

and look forward to trying out your macros you made for EagleFiler

Happy to hear that you want to try my macros, but…

Eagle Filer works perfectly fine without my macros! My macros are pure luxury, they only add some UI comfort. (They do not add functionality or work-arounds for bugs.)

So, if you are new to EagleFiler, my macros may even be confusing :wink: and it would perhaps be better to get familiar with EagleFiler (without any macros) first.

Just a thought…


Hi all, I am getting the following error:
I installed home-brew -
pngquant and I believe I set the path for home-brew correctly

any help is appreciated
error message follows:

MACRO ERROR  on  2017-02-27 09:18:37

This info was pulled from the KM Engine Log for the
Last Macro error that occured.

Macro: Trying
Action: Search Variable ‘pqScriptOut’ Using Regular Expression (case sensitive)
Status: cancelled
Error: Search Variable failed to match (?m)-color image as (.*?)$

Log File: ~/Library/Logs/Keyboard Maestro/Engine.log

Enter /usr/local/bin/pngquant in the Terminal and hit Return, to see if pngquant is found.

If it isn’t found, then find out where it has been installed.

If it is found:

Have you set KM’s ENV_PATH variable to include the /usr/local/bin path? (KM Editor > Preferences > Variables)

If ENV_PATH is not correctly set, then (create and) set the variable in KM’s preferences. For example to:


Note: You can also choose to set different paths. The important thing is that /usr/local/bin is included, and preferably at the beginning. Otherwise KM does not know where to find the Homebrew-installed tools.

See also Wiki.

Then test with this macro, to see if pngquant is found now:

_[test] Shell Test.kmmacros (1.4 KB)

1 Like

pngquant is found:

I'm not clear on what the path should be set to, I had:
But you had this:

I ran the shell test and get the following.

/var/folders/xt/7vy03w2x6t5gbpvdmj2mp7s80000gn/T/Keyboard-Maestro-Script-464A0ECF-DADA-4C47-B032-39CE2673426F: line 1: pngquant: command not found


/usr/local/bin works also. Make sure there is no newline (Return) at the end (after the bin).


I.e., this is correct:

This is wrong:

no carriage return there


The variable is named exactly ENV_PATH (case sensitive), right?

Try the Test macro with the explicit path:

Maybe the png I’m selecting isn’t 32 bit? would that be an error?

correct, case sensitive. ENV_PATH
ran with /usr/local/bin/pngquant


pngquant, 2.9.0 (December 2016), by Kornel Lesinski, Greg Roelofs.
Color profiles are supported via Cocoa. Using libpng 1.6.28.

usage: pngquant [options] [ncolors] – pngfile [pngfile …]
pngquant [options] [ncolors] - >stdout <stdin

–force overwrite existing output files (synonym: -f)
–skip-if-larger only save converted files if they’re smaller than original
–output file destination file path to use instead of --ext (synonym: -o)
–ext new.png set custom suffix/extension for output filenames
–quality min-max don’t save below min, use fewer colors below max (0-100)
–speed N speed/quality trade-off. 1=slow, 3=default, 11=fast & rough
–nofs disable Floyd-Steinberg dithering
–posterize N output lower-precision color (e.g. for ARGB4444 output)
–strip remove optional metadata (default on Mac)
–verbose print status messages (synonym: -v)

Quantizes one or more 32-bit RGBA PNGs to 8-bit (or smaller) RGBA-palette.
The output filename is the same as the input name except that
it ends in “-fs8.png”, “-or8.png” or your custom extension (unless the
input is stdin, in which case the quantized image will go to stdout).
The default behavior if the output file exists is to skip the conversion;
use --force to overwrite. See man page for full list of options.

No. If the Test macro finds /usr/local/bin/pngquant but it does not find pngquant, then something is wrong with your ENV_PATH variable.

You have a more or less current version of KM, right?

Some things you can try:

  • Restart the KM Engine: KM Editor > File > Quit Engine, then KM Editor > File > Launch Engine
  • Try to copy/paste the exact path from my example above to the ENV_PATH variable


If nothing works, can you post a screenshot with the ENV_PATH variable selected in KM Editor > Preferences > Variables?

AHEM, … sheepish stupid look on my face.
OH, you mean variable, NOT clipboard? I thought you meant clipboard… (not really)
ah, yeah, when I set the VARIABLE, ENV_PATH and NOT the clipboard… a, it worked like it should.
I’ll be crawling under a rock now. =) - LOL.
THANK you for your time, sorry for my mistake.
Have a Blessed day

Yep, I meant ‘variable’. Forgot to mention it :wink:

Great that it works now!

If you want to use also the advpng options don’t forget to install advpng:

brew install advancecomp

I’m tearing up with laughter… thanx you… really funny response.
installed advancecomp

all is working beautifully. nice!

Has anyone figured out a way to get optimized PNG output from pasteboard to apps? For example, when I copy a screenshot I've found that ImageOptim generally gets a 15-25% lossless size reduction via the pngcrush+PNGOUT. When these are pasted into apps (such as a chat system) directly they always result in unoptimized uploads, which is highly unfortunate... It would be so nice to have an automated optimized in-pasteboard to yield an optimized png output.

How exactly are you copying/uploading?

A) If you are copying the file path in the Finder and paste it, then the optimized file should get uploaded (as it is on your disk). But what then happens on the chat server, is another thing. For example there might be a server-side script that opens the uploaded PNG, scales or crops it, then re-saves it (unoptimized).

B) If you are opening the PNG on your computer (for example with Preview), then copy the content (⌘A ⌘C) and paste it: the unoptimized image data will get uploaded.

I'm sorry @Tom, I thought this was self-evident. I'm talking about copying directly with the image in the pasteboard (shift-control-command-4). So what you're talking about is #B where it's unoptimized image data. What is odd or confusing to me is that when you select different types of image encoding from, for example, Onyx, some apps honor the format (JPG, JP2, PNG, TIF, etc.) when the image is simply pasted in from the clipboard while others do not... This is why it makes me think there must be something else going on where this image can be further optimized and replaced within the pasteboard (clipboard).

The clipboard (after ⌃⇧⌘4) contains the “raw” image data (tiff) and the data in the format you specified (for example JPEG2000). I think, it is up to the app where you paste in, to decide which format it prefers.