@@ -7,6 +7,7 @@ The goals of v1 were to:
7
7
8
8
1 . Make jimp easier to use in any environment
9
9
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
10
11
11
12
## Positional Arguments to Options Objects
12
13
@@ -25,11 +26,6 @@ Now it looks like this:
25
26
image .resize ({ w: 100 , h: 100 });
26
27
```
27
28
28
- ### ` ResizeStrategy.AUTO `
29
-
30
- This constant was only needed for positional arguments.
31
- It is no longer needed with the new API.
32
-
33
29
## ` Jimp ` Constructor
34
30
35
31
The constructor for ` Jimp ` has changed.
@@ -102,4 +98,40 @@ import { Jimp } from "jimp";
102
98
async function main () {
103
99
const image = await Jimp .fromBitmap (bitmap);
104
100
}
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
0 commit comments