├── .npmrc ├── .gitattributes ├── .gitignore ├── screenshot.png ├── fixture ├── baseline.jpg └── progressive.jpg ├── .editorconfig ├── test.js ├── .github └── workflows │ └── main.yml ├── license ├── package.json ├── readme.md └── cli.js /.npmrc: -------------------------------------------------------------------------------- 1 | package-lock=false 2 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto eol=lf 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | yarn.lock 3 | -------------------------------------------------------------------------------- /screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sindresorhus/is-progressive-cli/HEAD/screenshot.png -------------------------------------------------------------------------------- /fixture/baseline.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sindresorhus/is-progressive-cli/HEAD/fixture/baseline.jpg -------------------------------------------------------------------------------- /fixture/progressive.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sindresorhus/is-progressive-cli/HEAD/fixture/progressive.jpg -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | indent_style = tab 5 | end_of_line = lf 6 | charset = utf-8 7 | trim_trailing_whitespace = true 8 | insert_final_newline = true 9 | 10 | [*.yml] 11 | indent_style = space 12 | indent_size = 2 13 | -------------------------------------------------------------------------------- /test.js: -------------------------------------------------------------------------------- 1 | import fs from 'node:fs'; 2 | import test from 'ava'; 3 | import {execa} from 'execa'; 4 | 5 | test('main', async t => { 6 | const {stdout} = await execa('./cli.js', ['fixture/progressive.jpg']); 7 | t.regex(stdout, /✔/); 8 | }); 9 | 10 | test('stdin', async t => { 11 | const {stdout} = await execa('./cli.js', { 12 | input: fs.readFileSync('fixture/progressive.jpg'), 13 | }); 14 | 15 | t.regex(stdout, /✔/); 16 | }); 17 | -------------------------------------------------------------------------------- /.github/workflows/main.yml: -------------------------------------------------------------------------------- 1 | name: CI 2 | on: 3 | - push 4 | - pull_request 5 | jobs: 6 | test: 7 | name: Node.js ${{ matrix.node-version }} 8 | runs-on: ubuntu-latest 9 | strategy: 10 | fail-fast: false 11 | matrix: 12 | node-version: 13 | - 20 14 | - 18 15 | steps: 16 | - uses: actions/checkout@v4 17 | - uses: actions/setup-node@v4 18 | with: 19 | node-version: ${{ matrix.node-version }} 20 | - run: npm install 21 | - run: npm test 22 | -------------------------------------------------------------------------------- /license: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) Sindre Sorhus (https://sindresorhus.com) 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 6 | 7 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 8 | 9 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 10 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "is-progressive-cli", 3 | "version": "3.0.0", 4 | "description": "Check if JPEG images are progressive", 5 | "license": "MIT", 6 | "repository": "sindresorhus/is-progressive-cli", 7 | "funding": "https://github.com/sponsors/sindresorhus", 8 | "author": { 9 | "name": "Sindre Sorhus", 10 | "email": "sindresorhus@gmail.com", 11 | "url": "https://sindresorhus.com" 12 | }, 13 | "type": "module", 14 | "bin": { 15 | "is-progressive": "./cli.js" 16 | }, 17 | "engines": { 18 | "node": ">=18" 19 | }, 20 | "scripts": { 21 | "test": "xo && ava" 22 | }, 23 | "files": [ 24 | "cli.js" 25 | ], 26 | "keywords": [ 27 | "cli-app", 28 | "cli", 29 | "jpg", 30 | "jpeg", 31 | "progressive", 32 | "file", 33 | "image", 34 | "img", 35 | "pic", 36 | "picture", 37 | "photo", 38 | "detect", 39 | "check", 40 | "is", 41 | "exif", 42 | "buffer", 43 | "stream", 44 | "fs" 45 | ], 46 | "dependencies": { 47 | "is-progressive": "^5.0.1", 48 | "log-symbols": "^6.0.0", 49 | "meow": "^13.2.0" 50 | }, 51 | "devDependencies": { 52 | "ava": "^6.1.3", 53 | "execa": "^9.3.0", 54 | "xo": "^0.58.0" 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | # is-progressive-cli 2 | 3 | > Check if JPEG images are [progressive](http://www.faqs.org/faqs/jpeg-faq/part1/section-11.html) 4 | 5 | 6 | 7 | Can be useful to make sure your images are progressive, which is important for performance: 8 | 9 | > Progressive JPEGs are better because they are faster. Appearing faster is being faster, and perceived speed is more important that actual speed. - [Progressive JPEGs: a new best practice](http://calendar.perfplanet.com/2012/progressive-jpegs-a-new-best-practice/) 10 | 11 | The check is fast as it only reads a small part of the file. 12 | 13 | ## Install 14 | 15 | ```sh 16 | npm install --global is-progressive-cli 17 | ``` 18 | 19 | ## Usage 20 | 21 | ``` 22 | $ is-progressive --help 23 | 24 | Usage 25 | $ is-progressive ... 26 | $ is-progressive < 27 | 28 | Example 29 | $ is-progressive baseline.jpg progressive.jpg 30 | ✖ baseline.jpg 31 | ✔ progressive.jpg 32 | ``` 33 | 34 | ##### Globbing 35 | 36 | You can use globs too if your shell supports that. 37 | 38 | ```sh 39 | is-progressive *.jpg 40 | ``` 41 | 42 | ## Related 43 | 44 | - [is-progressive](https://github.com/sindresorhus/is-progressive) - API for this package 45 | -------------------------------------------------------------------------------- /cli.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | import path from 'node:path'; 3 | import process from 'node:process'; 4 | import meow from 'meow'; 5 | import logSymbols from 'log-symbols'; 6 | import isProgressive from 'is-progressive'; 7 | 8 | const cli = meow(` 9 | Usage 10 | $ is-progressive ... 11 | $ is-progressive < 12 | 13 | Example 14 | $ is-progressive baseline.jpg progressive.jpg 15 | ✖ baseline.jpg 16 | ✔ progressive.jpg 17 | `, { 18 | importMeta: import.meta, 19 | }); 20 | 21 | const log = (isImageProgressive, imagePath) => { 22 | console.log(isImageProgressive ? logSymbols.success : logSymbols.error, path.relative('.', imagePath)); 23 | }; 24 | 25 | const init = input => { 26 | let exitCode = 0; 27 | 28 | for (const element of [input].flat()) { 29 | const isImageProgressive = isProgressive.fileSync(element); 30 | if (!isImageProgressive) { 31 | exitCode = 1; 32 | } 33 | 34 | log(isImageProgressive, element); 35 | } 36 | 37 | process.exitCode = exitCode; 38 | }; 39 | 40 | if (cli.input.length === 0 && process.stdin.isTTY) { 41 | console.error('Specify at least one filename'); 42 | process.exit(2); 43 | } 44 | 45 | if (cli.input.length > 0) { 46 | init(cli.input); 47 | } else { 48 | const stdin = await isProgressive.stream(process.stdin); 49 | log(stdin, 'stdin'); 50 | } 51 | --------------------------------------------------------------------------------