File tree 2 files changed +30
-0
lines changed
docs/src/content/docs/guides
2 files changed +30
-0
lines changed Original file line number Diff line number Diff line change @@ -155,6 +155,9 @@ export function createJimp<
155
155
/** Formats that can be used with Jimp */
156
156
formats : Format < any > [ ] = [ ] ;
157
157
158
+ /** The original MIME type of the image */
159
+ mime ?: string ;
160
+
158
161
constructor ( options : JimpConstructorOptions = emptyBitmap ) {
159
162
// Add the formats
160
163
this . formats = formats ;
@@ -327,6 +330,8 @@ export function createJimp<
327
330
await format . decode ( actualBuffer )
328
331
) as InstanceType < typeof CustomJimp > & ExtraMethodMap ;
329
332
333
+ image . mime = mime . mime ;
334
+
330
335
attemptExifRotate ( image , actualBuffer ) ;
331
336
332
337
return image ;
@@ -362,6 +367,16 @@ export function createJimp<
362
367
return "[object Jimp]" ;
363
368
}
364
369
370
+ /** Get the width of the image */
371
+ get width ( ) {
372
+ return this . bitmap . width ;
373
+ }
374
+
375
+ /** Get the height of the image */
376
+ get height ( ) {
377
+ return this . bitmap . height ;
378
+ }
379
+
365
380
/**
366
381
* Converts the Jimp instance to an image buffer
367
382
* @param mime The mime type to export to
Original file line number Diff line number Diff line change @@ -9,6 +9,14 @@ The goals of v1 were to:
9
9
2 . Make jimp's API more consistent and easier to use
10
10
3 . Many constants have been removed and are string value powered by TS
11
11
12
+ ## Importing
13
+
14
+ ` Jimp ` no longer uses a default export. Instead it uses named exports.
15
+
16
+ ``` js
17
+ import { Jimp } from " jimp" ;
18
+ ```
19
+
12
20
## Positional Arguments to Options Objects
13
21
14
22
In jimp v0 there were many ways to provide arguments to a method.
@@ -140,3 +148,10 @@ const resized = await image
140
148
141
149
- ` Jimp.AUTO ` - This constant was only needed for positional arguments. It is no longer needed with the new API.
142
150
- ` Jimp.MIME_* ` - These are now part of the TS api when encoding
151
+
152
+ ## Moved Functions
153
+
154
+ - ` Jimp.intToRGBA ` was moved ` import { intToRGBA } from "jimp"; `
155
+ - ` image.getHeight() ` was moved ` image.height `
156
+ - ` image.getWidth() ` was moved ` image.width `
157
+ - ` image.getMIME() ` was moved ` image.mime `
You can’t perform that action at this time.
0 commit comments