TinyPNG & TinyJPG in Command Line

tinypng-cli is an amazing tool to compress an image, or a directory of images with a single command. It’s beautiful for fixing the few images that a normal compressors miss or don’t do a good job on, or the images that slip between the cracks.

A big part of my day is ensuring all my sites have very high Google Page Speed scores, which are heavily factored by images alone. I sure I wish I had known about this tool years sooner, would of saved me hours of manually work.

Really simple to setup:

  • Get a API key from TinyPNG (free tier: 500 image cap)
  • Have npm installed on your server
  • Install tinypng-cli npm install -g tinypng-cli
  • Start compressing tinypng demo.png -k #####