Skip to content

Commit

Permalink
@jimp/cli (#606)
Browse files Browse the repository at this point in the history
* actually use parameters given to PNG.

* add colorType method to png type

* basic setup

* add actions

* add verbose output

* refactor a little bit

* add easy util functions

* add font loading

* add font loading

* add diff and distance

* testing works

* fix verbose mode

* test log

* test writing files

* factor out test tools and test verbose mode

* errorless should

* unused imports

* move load font into own file

* move constants out of function

* parse more arg types

* add usage examples

* add plugin loading

* also load types

* test plugin loading

* this doesn't provide any more info than nothing

* add readme and kinda fix types

* unused deps

* types broke

* run cli tests with whole repo

* lint

* delete test image after test

* add to main readme

* fix custom link

* more detailed custom docs

* refactor to read

* better actions handling a

* way better help output and add create image

* add bin

* test blit

* update readme

* update license strategy
  • Loading branch information
hipstersmoothie authored Sep 19, 2018
1 parent aefcc84 commit 7bab953
Show file tree
Hide file tree
Showing 33 changed files with 1,107 additions and 15 deletions.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ Installation: `npm install --save jimp`

API documentation can be found in the main [jimp package](./packages/jimp)

## Tools

:hammer: [cli](./packages/cli) - Jimp as a CLI program. Can load and run all plugins

## Supported Image Types

- [bmp](./packages/type-bmp)
Expand Down Expand Up @@ -49,7 +53,7 @@ API documentation can be found in the main [jimp package](./packages/jimp)

## Custom Jimp

If you want to extend jimp or omit types or functions visit [@jimp/custom](./packages).
If you want to extend jimp or omit types or functions visit [@jimp/custom](./packages/custom).

- Add file-types or switch encoder/decoders
- Add add/remove plugins (image manipulation methods)
Expand Down
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
},
"scripts": {
"lint": "xo",
"test": "cross-env BABEL_ENV=test mocha --require @babel/register './packages/**/test/**/*.test.js'",
"test": "cross-env BABEL_ENV=test mocha --require @babel/register './packages/**/test/**/*.test.js' --require ts-node/register ./packages/**/test/*.test.ts",
"test:watch": "npm run test -- --reporter min --watch",
"test:browser": "cross-env BABEL_ENV=test ENV=browser CHROME_BIN=\"$(which chrome || which chromium)\" karma start --single-run",
"test:browser:watch": "npm run -s test:browser start -- --auto-watch",
Expand Down Expand Up @@ -88,7 +88,9 @@
],
"ignores": [
"omggif.js",
"**/*.d.ts"
"**/*.ts",
"**/*.d.ts",
"*.ts"
],
"rules": {
"capitalized-comments": 0,
Expand Down
52 changes: 52 additions & 0 deletions packages/cli/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<div align="center">
<a href="https://intuit.github.io/Ignite/">
<img width="200" height="200"
src="https://s3.amazonaws.com/pix.iemoji.com/images/emoji/apple/ios-11/256/crayon.png">
</a>
<h1>@jimp/cli</h1>
<p>jimp on the cli</p>
</div>

Jimp on the CLI.

## Usage

Run with `--help` to get help information. Further help by running `--help <command>`. The two main functions are `read` and `create`.

```sh
jimp <command>

Commands:
jimp read [img] Read and image into jimp. (PNG, JPEG, TIFF, BMP, or GIF)
jimp create Create a new image
jimp distance [img1] [img2] Calculates the hamming distance of two images based on their
perceptual hash
jimp diff [img1] [img2] Diffs two images
jimp rgbaToInt A static helper method that converts RGBA values to a single
integer value. args: r, g, b, a (0 - 255)
jimp intToRGBA A static helper method that converts RGBA values to a single
integer value. args: num (eg 0xFF0000FF)
jimp cssColorToHex Converts a css color (Hex, 8-digit (RGBA) Hex, RGB, RGBA, HSL,
HSLA, HSV, HSVA, Named) to a hex number
jimp limit255 Limits a number to between 0 or 255. args: num
jimp compareHashes Calculates the hamming distance of two images based on their
perceptual hash. args: hash1, hash2
jimp colorDiff Compute color difference. args: color1, color2 ({r:val, g:val,
b:val, a:val})
jimp measureText Measure how wide printing a string will be. args: text
jimp measureTextHeight Measure how tall printing a string will be. args: text, width

Jimp Configuration:
--plugins, -p Jimp plugins to load. [array]
--types, -t Jimp types to load. [array]
--loadFont, -f Path of font to load and be used in text operations [string]

Options:
--help Show help [boolean]
--version Show version number [boolean]
--verbose, -v enable more logging [boolean]

Examples:
jimp read path/to/image.png --output output.jpg Convert images from one type to another. See
more under jimp read --help
```
1 change: 1 addition & 0 deletions packages/cli/babel.config.js
52 changes: 52 additions & 0 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
{
"name": "@jimp/cli",
"version": "0.4.0",
"description": "jimp on the cli",
"bin": {
"jimp": "dist/index.js"
},
"main": "dist/index.js",
"module": "es/index.js",
"scripts": {
"test": "mocha --require ts-node/register test/*.test.ts",
"test:coverage": "nyc npm run test -- --require source-map-support/register --recursive",
"build": "tsc",
"build:debug": "npm run build -- --sourceMap",
"build:watch": "npm run build -- --watch --sourceMap"
},
"author": "",
"license": "MIT",
"dependencies": {
"@jimp/custom": "^0.4.0",
"chalk": "^2.4.1",
"jimp": "^0.4.0",
"log-symbols": "^2.2.0",
"yargs": "^12.0.2"
},
"publishConfig": {
"access": "public"
},
"devDependencies": {
"@types/log-symbols": "^2.0.0",
"@types/mocha": "^5.2.5",
"@types/yargs": "^11.1.1",
"ts-node": "^7.0.1",
"typescript": "^3.0.3"
},
"nyc": {
"extension": [
".ts",
".tsx"
],
"include": [
"src/*.ts"
],
"reporter": [
"html",
"text"
]
},
"yargs": {
"flatten-duplicate-arrays": false
}
}
Loading

0 comments on commit 7bab953

Please sign in to comment.