Skip to content

Commit cf29f5b

Browse files
update more docs
1 parent b1c236a commit cf29f5b

File tree

19 files changed

+75
-1492
lines changed

19 files changed

+75
-1492
lines changed

packages/docs/src/content/docs/guides/migrate-to-v1.mdx

+38-6
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ The goals of v1 were to:
77

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

1112
## Positional Arguments to Options Objects
1213

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

28-
### `ResizeStrategy.AUTO`
29-
30-
This constant was only needed for positional arguments.
31-
It is no longer needed with the new API.
32-
3329
## `Jimp` Constructor
3430

3531
The constructor for `Jimp` has changed.
@@ -102,4 +98,40 @@ import { Jimp } from "jimp";
10298
async function main() {
10399
const image = await Jimp.fromBitmap(bitmap);
104100
}
105-
```
101+
```
102+
103+
## Encoding and Decoding Options
104+
105+
Another area where the API has changed is the way that encodings and decoding are handled.
106+
107+
Previously the options were global and it was confusing where they might be applied (unless you have experience with the underlying image codecs).
108+
109+
For example in v0 if you wanted to export a JPEG with the quality set to 80% you would do this:
110+
111+
```js
112+
import { Jimp } from "jimp";
113+
114+
const image = new Jimp(...);
115+
116+
const resized = await image
117+
.resize(512, Jimp.AUTO)
118+
.quality(80)
119+
.getBufferAsync(Jimp.MIME_JPEG);
120+
```
121+
122+
In v1 the options are passed when you get the encoded image:
123+
124+
```js
125+
import { Jimp } from "jimp";
126+
127+
const image = new Jimp(...);
128+
129+
const resized = await image
130+
.resize({ w: 512 })
131+
.getBufferAsync('image/jpeg', { quality: 80 });
132+
```
133+
134+
## Removed Constants
135+
136+
- `Jimp.AUTO` - This constant was only needed for positional arguments. It is no longer needed with the new API.
137+
- `Jimp.MIME_*` - These are now part of the TS api when encoding

plugins/js-jpeg/README.md

-6
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,3 @@
44
<h1>@jimp/jpeg</h1>
55
<p>Default Jimp jpeg encoder/decoder.</p>
66
</div>
7-
8-
## Available Methods
9-
10-
### Jimp.quality
11-
12-
Sets the quality of the image when saving as JPEG format (default is 100)

plugins/plugin-blit/README.md

+1-25
Original file line numberDiff line numberDiff line change
@@ -7,28 +7,4 @@
77

88
> Blit - a data operation commonly used in computer graphics in which several bitmaps are combined into one using a boolean function.
99
10-
## Usage
11-
12-
Blits a source image on to this image
13-
14-
- @param {Jimp} src image to blit
15-
- @param {number} x the x position to blit the image
16-
- @param {number} y the y position to blit the image
17-
- @param {number} srcx (optional) the x position from which to crop the source image
18-
- @param {number} srcy (optional) the y position from which to crop the source image
19-
- @param {number} srcw (optional) the width to which to crop the source image
20-
- @param {number} srch (optional) the height to which to crop the source image
21-
- @param {function(Error, Jimp)} cb (optional) a callback for when complete
22-
23-
```js
24-
import jimp from "jimp";
25-
26-
async function main() {
27-
const image = await jimp.read("test/image.png");
28-
const parrot = await jimp.read("test/party-parrot.png");
29-
30-
image.blit(parrot, x, y);
31-
}
32-
33-
main();
34-
```
10+
[Read the docs](http://jimp-dev.github.io/jimp/api/jimp/classes/jimp#blit)

plugins/plugin-blur/README.md

+2-37
Original file line numberDiff line numberDiff line change
@@ -7,40 +7,5 @@
77

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

10-
## Usage
11-
12-
### `blur`
13-
14-
- @param {number} r the pixel radius of the blur
15-
- @param {function(Error, Jimp)} cb (optional) a callback for when complete
16-
17-
```js
18-
import jimp from "jimp";
19-
20-
async function main() {
21-
const image = await jimp.read("test/image.png");
22-
23-
image.blur(5);
24-
}
25-
26-
main();
27-
```
28-
29-
Applies a true Gaussian blur to the image (warning: this is VERY slow)
30-
31-
### `gaussian`
32-
33-
- @param {number} r the pixel radius of the blur
34-
- @param {function(Error, Jimp)} cb (optional) a callback for when complete
35-
36-
```js
37-
import jimp from "jimp";
38-
39-
async function main() {
40-
const image = await jimp.read("test/image.png");
41-
42-
image.gaussian(15);
43-
}
44-
45-
main();
46-
```
10+
- [blur](http://jimp-dev.github.io/jimp/api/jimp/classes/jimp#blur)
11+
- [gaussian](http://jimp-dev.github.io/jimp/api/jimp/classes/jimp#gaussian)

plugins/plugin-circle/README.md

+1-18
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,4 @@
55
<p>Creates a circle out of an image.</p>
66
</div>
77

8-
## Usage
9-
10-
- @param {function(Error, Jimp)} options (optional) radius, x, y
11-
- @param {function(Error, Jimp)} cb (optional) a callback for when complete
12-
13-
```js
14-
import jimp from "jimp";
15-
16-
async function main() {
17-
const image = await jimp.read("test/image.png");
18-
19-
image.circle();
20-
// or
21-
image.circle({ radius: 50, x: 25, y: 25 });
22-
}
23-
24-
main();
25-
```
8+
- [circle](http://jimp-dev.github.io/jimp/api/jimp/classes/jimp#circle)

0 commit comments

Comments
 (0)