Skip to content

Commit

Permalink
update more docs
Browse files Browse the repository at this point in the history
  • Loading branch information
hipstersmoothie committed Sep 1, 2024
1 parent b1c236a commit cf29f5b
Show file tree
Hide file tree
Showing 19 changed files with 75 additions and 1,492 deletions.
44 changes: 38 additions & 6 deletions packages/docs/src/content/docs/guides/migrate-to-v1.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ The goals of v1 were to:

1. Make jimp easier to use in any environment
2. Make jimp's API more consistent and easier to use
3. Many constants have been removed and are string value powered by TS

## Positional Arguments to Options Objects

Expand All @@ -25,11 +26,6 @@ Now it looks like this:
image.resize({ w: 100, h: 100 });
```

### `ResizeStrategy.AUTO`

This constant was only needed for positional arguments.
It is no longer needed with the new API.

## `Jimp` Constructor

The constructor for `Jimp` has changed.
Expand Down Expand Up @@ -102,4 +98,40 @@ import { Jimp } from "jimp";
async function main() {
const image = await Jimp.fromBitmap(bitmap);
}
```
```

## Encoding and Decoding Options

Another area where the API has changed is the way that encodings and decoding are handled.

Previously the options were global and it was confusing where they might be applied (unless you have experience with the underlying image codecs).

For example in v0 if you wanted to export a JPEG with the quality set to 80% you would do this:

```js
import { Jimp } from "jimp";

const image = new Jimp(...);

const resized = await image
.resize(512, Jimp.AUTO)
.quality(80)
.getBufferAsync(Jimp.MIME_JPEG);
```

In v1 the options are passed when you get the encoded image:

```js
import { Jimp } from "jimp";

const image = new Jimp(...);

const resized = await image
.resize({ w: 512 })
.getBufferAsync('image/jpeg', { quality: 80 });
```

## Removed Constants

- `Jimp.AUTO` - This constant was only needed for positional arguments. It is no longer needed with the new API.
- `Jimp.MIME_*` - These are now part of the TS api when encoding
6 changes: 0 additions & 6 deletions plugins/js-jpeg/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,3 @@
<h1>@jimp/jpeg</h1>
<p>Default Jimp jpeg encoder/decoder.</p>
</div>

## Available Methods

### Jimp.quality

Sets the quality of the image when saving as JPEG format (default is 100)
26 changes: 1 addition & 25 deletions plugins/plugin-blit/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,4 @@

> Blit - a data operation commonly used in computer graphics in which several bitmaps are combined into one using a boolean function.
## Usage

Blits a source image on to this image

- @param {Jimp} src image to blit
- @param {number} x the x position to blit the image
- @param {number} y the y position to blit the image
- @param {number} srcx (optional) the x position from which to crop the source image
- @param {number} srcy (optional) the y position from which to crop the source image
- @param {number} srcw (optional) the width to which to crop the source image
- @param {number} srch (optional) the height to which to crop the source image
- @param {function(Error, Jimp)} cb (optional) a callback for when complete

```js
import jimp from "jimp";

async function main() {
const image = await jimp.read("test/image.png");
const parrot = await jimp.read("test/party-parrot.png");

image.blit(parrot, x, y);
}

main();
```
[Read the docs](http://jimp-dev.github.io/jimp/api/jimp/classes/jimp#blit)
39 changes: 2 additions & 37 deletions plugins/plugin-blur/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,40 +7,5 @@

A fast blur algorithm that produces similar effect to a Gaussian blur - but MUCH quicker

## Usage

### `blur`

- @param {number} r the pixel radius of the blur
- @param {function(Error, Jimp)} cb (optional) a callback for when complete

```js
import jimp from "jimp";

async function main() {
const image = await jimp.read("test/image.png");

image.blur(5);
}

main();
```

Applies a true Gaussian blur to the image (warning: this is VERY slow)

### `gaussian`

- @param {number} r the pixel radius of the blur
- @param {function(Error, Jimp)} cb (optional) a callback for when complete

```js
import jimp from "jimp";

async function main() {
const image = await jimp.read("test/image.png");

image.gaussian(15);
}

main();
```
- [blur](http://jimp-dev.github.io/jimp/api/jimp/classes/jimp#blur)
- [gaussian](http://jimp-dev.github.io/jimp/api/jimp/classes/jimp#gaussian)
19 changes: 1 addition & 18 deletions plugins/plugin-circle/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,4 @@
<p>Creates a circle out of an image.</p>
</div>

## Usage

- @param {function(Error, Jimp)} options (optional) radius, x, y
- @param {function(Error, Jimp)} cb (optional) a callback for when complete

```js
import jimp from "jimp";

async function main() {
const image = await jimp.read("test/image.png");

image.circle();
// or
image.circle({ radius: 50, x: 25, y: 25 });
}

main();
```
- [circle](http://jimp-dev.github.io/jimp/api/jimp/classes/jimp#circle)
Loading

0 comments on commit cf29f5b

Please sign in to comment.