• Stars
    star
    3,452
  • Rank 12,926 (Top 0.3 %)
  • Language
    TypeScript
  • License
    MIT License
  • Created almost 12 years ago
  • Updated 2 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Make optimisation of images part of your automated build process

ImageOptim-CLI

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

NPM version NPM downloads Build Status Maintainability

Table of Contents

πŸ“£ 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

npm

npm install -g imageoptim-cli

homebrew

brew update
brew install imageoptim-cli

Manual

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

# go to home directory
cd ~
# download the tarball (change 3.0.7 to latest version if available)
curl --output imageoptim-cli.tgz https://registry.npmjs.org/imageoptim-cli/-/imageoptim-cli-3.0.7.tgz
# extract the tarball
tar -xvzf ./imageoptim-cli.tgz
# delete the tarball
rm imageoptim-cli.tgz
# rename the directory extracted from the tarball
mv ./package ./imageoptim-cli
# make imageoptim command available in your terminal
export PATH=$PATH:imageoptim-cli/dist

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

$ imageoptim --help

  Usage: imageoptim [options] [patterns...]

  Options:

    -V, --version           output the version number
    -a, --imagealpha        enable ImageAlpha
    -j, --jpegmini          enable JPEGmini
    -C, --no-color          output to the terminal without colors
    -I, --no-imageoptim     disable ImageOptim
    -Q, --no-quit           do not quit apps once finished
    -S, --no-stats          do not display file size savings and quality loss information
    --number-of-colors <n>  ImageAlpha palette size, defaults to 256
    --quality <min>-<max>   ImageAlpha quality range from 0-100, defaults to 65-80
    --speed <n>             ImageAlpha speed from 1 (brute-force) to 10 (fastest), defaults to 1
    -h, --help              output usage information

  Supported Apps:

    ImageAlpha: https://pngmini.com
    ImageOptim: https://imageoptim.com
    JPEGmini Lite: https://itunes.apple.com/us/app/jpegmini-lite/id525742250
    JPEGmini Pro: https://itunes.apple.com/us/app/jpegmini-pro/id887163276
    JPEGmini: https://itunes.apple.com/us/app/jpegmini/id498944723

  Examples:

    Run ImageOptim.app over every image in current directory
    imageoptim

    Run ImageAlpha.app and ImageOptim.app over every PNG in current directory
    imageoptim --imagealpha '**/*.png'

    Run JPEGmini.app and ImageOptim.app over every JPG in current directory
    imageoptim --jpegmini '**/*.jpg' '**/*.jpeg'

    Run ImageOptim.app over every image in a specific directory
    imageoptim '~/Desktop'

⚠️ 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

How Optimized Are Your Images? Meet ImageOptim-CLI, a Batch Compression Tool

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

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

Yes.

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 ❀️

πŸ€“ 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.

Follow JamieMason on GitHubΒ Β Β Β Β Β Follow fold_left on Twitter

More Repositories

1

syncpack

Consistent dependency versions in large JavaScript Monorepos.
TypeScript
1,426
star
2

shrinkpack

Fast, resilient, reproducible builds with npm install.
TypeScript
793
star
3

Jasmine-Matchers

Write Beautiful Specs with Custom Matchers for Jest and Jasmine
JavaScript
586
star
4

grunt-imageoptim

Make ImageOptim, ImageAlpha and JPEGmini part of your automated build process
JavaScript
479
star
5

expect-more

Curried Type Testing library, and Test Matchers for Jest
TypeScript
172
star
6

astexplorer.app

An https://astexplorer.net wrapper which adds module bundling and hot reloading.
TypeScript
120
star
7

karma-benchmark

A Karma plugin to run Benchmark.js over multiple browsers with CI compatible output.
TypeScript
90
star
8

codemods

A collection of transforms for use with JSCodeshift
JavaScript
59
star
9

blurhash-to-css

Convert BlurHashes to CSS Objects using TypeScript, Rust, and WebAssembly.
TypeScript
56
star
10

eslint-plugin-prefer-arrow-functions

Auto-fix plain Functions into Arrow Functions, in all cases where conversion would result in the same behaviour
TypeScript
52
star
11

karma-jasmine-matchers

A Karma plugin to inject Jasmine-Matchers for Jasmine and Jest.
JavaScript
46
star
12

nextjs-typescript-tailwind-critical-css

Next.js 9.3 with TypeScript, tailwindcss, and inlined Critical CSS.
TypeScript
41
star
13

eslint-formatter-git-log

ESLint Formatter featuring Git Author, Date, and Hash
TypeScript
41
star
14

ts-import-types-cli

Autofix TypeScript types to be imported using `import type`
TypeScript
40
star
15

self-help

Interactive Q&A Guides for Web and the Command Line.
TypeScript
37
star
16

image-optimisation-tools-comparison

A Benchmarking Suite for popular Image Optimisation Tools
TypeScript
28
star
17

Unreadable

An intelligent/CSS-aware HTML Minifier and Optimizer
JavaScript
26
star
18

custom-linkedin-cv

LinkedIn profile JSON + AngularJS == Custom RΓ©sumΓ©
CSS
23
star
19

add-matchers

Write useful test matchers compatible with Jest and Jasmine.
JavaScript
18
star
20

syncpack-github-action

A GitHub Action to synchronise monorepo dependency versions with syncpack.
14
star
21

karma-nested-reporter

Easy to read test output with nested describe and it blocks
JavaScript
14
star
22

devtools-extension-tab-colours

Adds colours to the tabs in Chrome DevTools.
CSS
11
star
23

glob-bus

249 byte event emitter / pubsub with namespaced wildcards.
TypeScript
10
star
24

phantomjs-test-starter

A boilerplate / starter template for testing PhantomJS β€˜Applications’ with Jasmine, Grunt and Istanbul
JavaScript
8
star
25

eslint-plugin-move-files

Move and rename files while keeping imports up to date
TypeScript
8
star
26

logservable

git log as an observable stream of JSON
TypeScript
8
star
27

subclass.js

Inherit, extend, decorate, and override classes and instances.
JavaScript
7
star
28

Jasmine-Matchers-Snippets

Snippets for Jest & Jasmine Matchers.
6
star
29

react-xstate-pull-to-refresh

Created with CodeSandbox
TypeScript
6
star
30

giterator

`git log` as a JavaScript generator
TypeScript
5
star
31

grunt-rewrite

A Grunt plugin to edit & replace file contents.
JavaScript
5
star
32

conventional-recommended-version

Determine the semantic version number of your project
TypeScript
5
star
33

csslib

A customised fork of inuitcss which I use on most projects.
CSS
5
star
34

node-es6-starter

babel, code climate, commitizen, coveralls, easystatic, ghooks, istanbul, jasmine, rollup, travis, xo.
JavaScript
4
star
35

peach.js

A precompiled forEach, unrolled for faster runtime performance.
JavaScript
4
star
36

doei

Experiment: Remove unused CSS/JS using RUM Code Coverage
TypeScript
4
star
37

Tim

Node.js, Express & MongoDB app starter template with multi-language support, user registration and authentication
JavaScript
4
star
38

jest-fail-on-console-reporter

Disallow untested console output produced during tests
TypeScript
2
star
39

treeify

Format an indented text file in the style of the Linux tree command
JavaScript
2
star
40

valueless

Replace values with paths, for use in test fixtures
JavaScript
2
star
41

lastfm-to-itunes

JavaScript
2
star
42

generator-jekyll-inuit

A Jekyll Website with Inuit.css generator for Yeoman
CSS
2
star
43

shrinkpack-examples

Examples of monorepos using shrinkpack to install while offline.
2
star
44

get-time-between

Measure the amount of time during work hours between two dates
TypeScript
2
star
45

is-office-hours

Determine whether a given date is within office hours
TypeScript
2
star
46

Jasmine-Matchers-ES6-Snippets

ES6 Snippets for Jest & Jasmine Matchers.
2
star
47

next-optimized-head

Next.js `<Head/>` which orders elements to improve (perceived) page performance.
TypeScript
2
star
48

commit-release

Commit and tag a conventional changelog release
TypeScript
1
star
49

front-end-engineer-interview-exercise

How do other Developers approach interview exercises?
1
star
50

github-actions-temporary-repo

JavaScript
1
star