ImageAlpha



Automates ImageOptim, ImageAlpha, and JPEGmini for Mac to make batch optimisation of images part of your automated build process.

Table of Contents

ImageAlpha - Mac GUI for pngquant, pngnq and posterizer. Imagine - Imagine is a desktop app for compression of PNG and JPEG, with a modern and friendly UI. InVesalius - 3D medical imaging reconstruction software; Katana - Katana is a simple screenshot utility for macOS that lives in your menubar. ImageOptim is excellent for publishing images on the web (easily shrinks images “Saved for Web” in Photoshop). It's useful for making Mac and iPhone / iPad applications smaller (if you configure Xcode to allow better optimization). Download Insomnia the best API Client for REST, GraphQL, GRPC and OpenAPI design tool for developers. ImageAlpha converts 24-bit PNG to paletted 8-bit with full alpha channel. This greately reduces file sizes with only minor loss of quality. Such images are compatible with all browsers, and even.

📣 Summary

While other image optimization tools are available from the command line, ImageOptim-CLI exists because the current benchmarks suggest that ImageOptim, ImageAlpha and JPEGmini currently outperform those alternatives over lossless and lossy optimizations.

ImageOptim-CLI is written in TypeScript and AppleScript but is distributed as a self-contained executable binary, you don't need Node.js installed to use ImageOptim-CLI.

Check out this short video demo of ImageOptim-CLI to see how it works.

🌩 Installation

Manual

Otherwise, you can install manually by downloading the latest release then adding ImageOptim-CLI to your $PATH.

Saving somewhere in your home directory such as ~/imageoptim-cli is recommended, but not essential. Saving to /Applications is not recommended, do not do this.

🕹 Usage

⚠️ JPEGmini and support for assistive devices

You may be presented with the following message the first time you run ImageOptim-CLI with the --jpegmini flag.

To automate JPEGmini we need to add Terminal.app (or iTerm.app etc) to the 'support for assistive devices' whitelist.

The JPEGmini OS X Apps don't include a command line API, so a real user is simulated by entering synthetic clicks and keyboard commands instead. This requires your permission and is easily set up in System Preferences as shown by these guides.

💡 Related Projects

Grunt Plugin

The ImageOptim-CLI Grunt plugin is grunt-imageoptim.

Comparison of image optimization tools

ImageOptim-CLI features in this comparison of the performance of image optimisation tools alongside Kraken.io, CodeKit, grunt-contrib-imagemin, Smush.it, and TinyPNG.

Article for Smashing Magazine

Alfred Workflow

The ImageOptim-CLI Workflow for Alfred app is alfred-image-optim-workflow

FAQs

General

Do ImageOptim, ImageAlpha, or JPEGmini come bundled with the ImageOptim-CLI installation?

You will need to install these applications separately.

Do I have to pay to use ImageOptim-CLI?

The CLI, ImageOptim and ImageAlpha are all free. JPEGmini is a paid-for product but you can use ImageOptim-CLI and choose not to run JPEGmini.

The WebP image format looks promising, can you get ImageOptim-CLI to convert images to it?

WebP looks great and may well overtake the formats handled by ImageOptim-CLI, but converting images to WebP is outside ImageOptim-CLI's chosen remit.

Can you get ImageOptim-CLI to skip images it has already processed, if they haven't changed?

JPEGmini does this today, but for ImageOptim and ImageAlpha I feel a feature like this belongs in those applications rather than this automator.

ImageOptim

ImageOptim makes the fans on my Mac run at full power.

Optimising images is a pretty intensive process, so instead of optimising one image at a time (which would take forever) — ImageOptim optimises many images at the same time until all of them are done.

A side effect of this is that the fans come on at full power to keep your machine cool while it's maxed out.

ImageAlpha

I don't think ImageAlpha is running, I can't see anything.

ImageOptim-CLI uses ImageAlpha's internal installation of pngquant so it's normal that nothing is shown on screen.

It's also possible that if you look in the Activity Monitor you will not see pngquant displayed but it is being run. In my experience it's only when you run ImageOptim-CLI on a very large number of PNGs that you have enough time to spot it. ensure that Activity Monitor's Update Frequency is set to Very Often (1 sec).

JPEGmini

Png Optimizer Windows

Can I use ImageOptim-CLI with JPEGmini Lite, the free version of JPEGmini?

Yes.

ImageAlpha

I upgraded from JPEGmini Lite to JPEGmini but ImageOptim-CLI still says JPEGmini is not installed.

Performing the in-app upgrade leaves the app named as jpegmini-lite, so ImageOptim-CLI can't determine whether it's the free or full version. It is better to instead buy the full version of JPEGmini separately.

ImageOptim-CLI says “To automate JPEGmini we need to enable GUI Scripting”, how do I do that?

See this tutorial on how to manage Accessibility preferences and GUI Scripting. In the case of OS X Mavericks, you will want to add the Applications JPEGmini and Terminal (or equivalent such as iTerm).

Windows and Linux

Can I use ImageOptim-CLI on Windows or Linux?

ImageOptim-CLI is responsible for automating 3 OS X applications so is inherently bound to OS X for that reason.

Are there any plans for ImageOptim-CLI to support Windows or Linux?

It would first require ImageOptim, ImageAlpha, and JPEGmini to be available for those platforms.

I don't have OS X, can you recommend an alternative to ImageOptim-CLI?

@addyosmani wrote a really thorough article on tools for image optimization which discusses a wide range of options in great detail.

⚙️ Contributing

Have an idea? Found a bug? Please see the Contributing Guide for information on how to install the project and start writing code.

🙋🏿‍♀️ Getting Help

Get help with issues by creating a Bug Report or discuss ideas by opening a Feature Request.

👀 Other Projects

If you find my Open Source projects useful, please share them ❤️

Imagealpha Brew

  • eslint-formatter-git-log
    ESLint Formatter featuring Git Author, Date, and Hash
  • eslint-plugin-move-files
    Move and rename files while keeping imports up to date
  • eslint-plugin-prefer-arrow-functions
    Convert functions to arrow functions
  • Jasmine-Matchers
    Write Beautiful Specs with Custom Matchers
  • karma-benchmark
    Run Benchmark.js over multiple Browsers, with CI compatible output
  • self-help
    Interactive Q&A Guides for Web and the Command Line
  • syncpack
    Manage multiple package.json files, such as in Lerna Monorepos and Yarn Workspaces

🤓 Author

I'm Jamie Mason from Leeds in England, I began Web Design and Development in 1999 and have been Contracting and offering Consultancy as Fold Left Ltd since 2012. Who I've worked with includes Sky Sports, Sky Bet, Sky Poker, The Premier League, William Hill, Shell, Betfair, and Football Clubs including Leeds United, Spurs, West Ham, Arsenal, and more.

Have you ever tried to download a large app in the App Store, only to see Apple’s 100MB warning?

In order to download apps from the App Store that exceed 100MB, you have to use a Wi-Fi network instead of a cellular network. It’s a rule designed to help you save cellular data, but it’s kind of a nuisance. Sure, you can download the app later once you find some Wi-Fi, but what if you want satisfaction now? Moreover, what if you forget to download it later?

That’s the worry for many app developers, who know just how hard it is to get downloads in the first place. You don’t want to have any extra obstacles between your app and its potential users. Unfortunately, it has become harder and harder to keep apps under the 100MB threshold. As Apple keeps introducing newer devices with larger retina displays, developers have to include larger images in their app bundles. This is especially troubling for games, which often have hundreds of image assets. It doesn’t take long before you have a wealth of PNG files (with at least two duplicates of each image in different sizes to handle different devices) totaling a couple hundred MB in size.

Image Alpha Centauri

This once seemed like an insurmountable challenge, but it’s a lot easier to manage than you probably expect. We’ll just cut the file sizes by about 75% with negligible downside!

ImageAlpha

ImageAlpha allows you to reduce the file size of PNG images with lossy compression by reducing the number of colors. Just saving everything at 256 colors will probably reduce your file sizes by around 70% with barely any discernible difference. For large background images, I like to try reducing to 128 colors and see if the image still looks good. If you still need to shrink your app bundle size, you can get creative and strategically reduce the colors on other images. Even if you stick to 256 colors, this is truly a game changing amount of file size reduction. You can download ImageAlpha here.

Since you’ll want to use ImageAlpha on every image in your project, it may be easier to process all of your images at once. If you know you’re going to set everything to 256 colors, batch processing is certainly the way to go. If you’re comfortable with the command line, open up Terminal.

Assuming ImageAlpha is in your Applications folder, type in the following, but don’t hit enter yet.

We’re going to run pngquant, the file size reduction tool behind ImageAlpha. The rest of the command notes that we want to use .png for our new file extensions and overwrite the old files with 256 color images. Before hitting enter, highlight all of the files in finder that you want to shrink and drag them into the terminal window. You’ll see a list of all their file paths appended to the command you just wrote. Finally, press enter. Your images have now been converted!

ImageOptim

ImageOptim further reduces file sizes by removing metadata, comments, and other unnecessary information stored in the PNG files. This doesn’t reduce your image quality at all, so there’s no downside here. You won’t get the same file size savings that ImageAlpha generates—usually only 3 to 6%—but every little bit helps. Note that you can go to preferences to set how aggressive you want the optimization to be. More savings takes more time. You can even run ImageOptim multiple times and sometimes save a little more space on subsequent runs. You can download ImageOptim here.

Once you have both programs downloaded, ImageAlpha and ImageOptim are designed to run in concert with each other. When you’re finished saving your image with ImageAlpha, you will see an option to run ImageOptim. It’s space saving extravaganza! Your images are now probably a quarter of their original size, and you should have a much easier time staying under the 100MB limit.

Required Xcode Setting

There’s one more thing you need to do to maintain all your newfound savings. Xcode has its own PNG compression tool that saves a minimal amount of space. By default, it will convert all of your images, and, in the process, negate your file size savings. Don’t let Xcode do this to you. Go to your project’s “Build Settings” and change “Compress PNG Files” to “No.” There you have it! Now your users can get your app even when they don’t have access to Wi-Fi.