PNG Optimizer

A (probably) stupid question:

  • It it is set to jpg or tiff, right?

[Edit 2016-04-22:]
The above comment was for the Enhanced Screenshot Macro. So, forget it.

You mean I selected a JPEG or TIFF? No, only PNG.


Cary

Please see my edited post above. I have to grab some sleep right now, you’ll here from m soon :roll_eyes:

Tom,

I found something strange. If I set the ENV_PATH variable = /usr/local/bin, all the shell scripts available in Keyboard Maestro cease to function. All of them return “xxx: command not found”. If I delete the ENV_PATH variable from the preferences, the shell scripts work again but, of course, PNG Optimizer ceases to function.

Cary

Cary, doing that removes the default paths to the other programs. If you set the ENV_PATH variable in the preferences, you need to include the base paths along with any additional paths. So you would set ENV_PATH to be /usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin

Tom: FYI if you want to update the top post, the AdvanceCOMP package, containing advpng, can be installed with brew install AdvanceCOMP. A good alternative to downloading the source and compiling it.

1 Like

Great find! Thanks! I was already wondering why it was missing in Homebrew but I was too stupid to have a closer look at the repository…

[Edit:] A added your tipp to the post above and to the Enhanced Screenshot post. Thanks again.

I would put the the more “current” (specialized) local paths at the front, like this:

/usr/local/bin:/usr/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin

1 Like

Also available from Macports.

port info AdvanceCOMP
sudo port -v install AdvanceCOMP

Confirmed that it installs advancecomp v1.20.

-Chris

Thanks guys,

Everything works fine now. Including ImageOptim :grinning:


Cary

Updated for macOS Sierra

If you are using Sierra (10.12) please redownload the updated macro from the download link in the original post. (It should work with both El Capitan and Sierra.)

1.0.1

  • HTML prompt updated for macOS Sierra.
  • Spotlight comment now gets written also when advpng is disabled.
  • Changed some defaults: Speed -> 1, Dither -> 1, advpng -> 7z.

Do you know of a way to reduce screenshots saved to the clipboard? I often save notes about software in a Scrivener file and save the file first to the desktop and then drag it into Squash and then drag the output image into Scrivener to keep the file size down. There is of course way too much friction in that when I am trying to take notes and keep in the flow of what I am doing.

I’ll continue searching but thought I would ask since this seems close to what I am trying to do.

Do you know of a way to reduce screenshots saved to the clipboard?

As far as I know the clipboard always holds the uncompressed image data (public.tiff). So I don’t think it’s possible.

I also tried it with with pbpaste and pngquant in the shell, but it seems pngquant only reads from file (?).

I often save notes about software in a Scrivener file and save the file first to the desktop and then drag it into Squash and then drag the output image into Scrivener to keep the file size down. There is of course way too much friction in that when I am trying to take notes and keep in the flow of what I am doing.

Not sure if I understand correctly, but assuming you speak about screenshots which are part of your software notes, I would do this workflow:

  1. Drag your (unoptimized) screenshot PNGs into Scrivener. (Into the sidebar, not into a text document!)

  2. Once you have collected a fair number of PNGs open the Scrivener document bundle in the Finder (right-click, Show Package Contents).

  3. Select all the PNGs. It should look like this:

  4. Run my PNG Optimizer macro on the selected files (in one go). Important:

  • Select “Overwrite existing files”
  • Select File naming: “Overwrite original file”
  1. The result will be something like this:

This way it takes about 30s to optimize 30 PNGs. As long as you don’t change the output file names, Scrivener will be content.

Thanks Tom for the help with this and the details on the Scrivener workflow.

That is interesting in your picture that you got all those images below your trash. I didn't think and can't get anything below my trash it always has to stay in the research folder. Regardless that is a pretty cool idea that helps some but mostly my files are always stored in the text document which as you know Scrivener saves as .rtf so I can't optimize the images at that point.

I'll keep hunting for a solution if possible.

Uhps, don’t do that! If you drag them into the RTF the image data gets hex-encoded and you get twice the file size, no matter if the PNG was optimized before or not. If you leave them stored as individual files inside the document bundle (as shown) they keep their original format and size.

That is interesting in your picture that you got all those images below your trash. I didn't think and can't get anything below my trash it always has to stay in the research folder.

I think it doesn’t matter if they are inside the Research folder or just in the sidebar. If you open the document bundle they seem to be always in the “Docs” subfolder.

Yikes, I never checked that, now I am even more depressed about what I have been doing than before! I just did a test and a 2.1MB image made a new document jump to 4.2MB. Optimizing that same image made the image 1.2MB and then when dragged into Scrivener went up to 3.4MB so more than double but not quite as much as the none optimized image (I see no noticeable difference between the optimized and not optimized when using Squash.app).

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. Your information was much like watching the daily news, I feel informed yet sad. In all seriousness though thank you for making me aware of that.

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

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…

2 Likes