Skip to content

Commit b49a523

Browse files
Add width/height/mime getters
1 parent 91bb998 commit b49a523

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

packages/core/src/index.ts

+15
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,9 @@ export function createJimp<
155155
/** Formats that can be used with Jimp */
156156
formats: Format<any>[] = [];
157157

158+
/** The original MIME type of the image */
159+
mime?: string;
160+
158161
constructor(options: JimpConstructorOptions = emptyBitmap) {
159162
// Add the formats
160163
this.formats = formats;
@@ -327,6 +330,8 @@ export function createJimp<
327330
await format.decode(actualBuffer)
328331
) as InstanceType<typeof CustomJimp> & ExtraMethodMap;
329332

333+
image.mime = mime.mime;
334+
330335
attemptExifRotate(image, actualBuffer);
331336

332337
return image;
@@ -362,6 +367,16 @@ export function createJimp<
362367
return "[object Jimp]";
363368
}
364369

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+
365380
/**
366381
* Converts the Jimp instance to an image buffer
367382
* @param mime The mime type to export to

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

+7
Original file line numberDiff line numberDiff line change
@@ -140,3 +140,10 @@ const resized = await image
140140

141141
- `Jimp.AUTO` - This constant was only needed for positional arguments. It is no longer needed with the new API.
142142
- `Jimp.MIME_*` - These are now part of the TS api when encoding
143+
144+
## Moved Functions
145+
146+
- `Jimp.intToRGBA` was moved `import { intToRGBA } from "jimp";`
147+
- `image.getHeight()` was moved `image.height`
148+
- `image.getWidth()` was moved `image.width`
149+
- `image.getMIME()` was moved `image.mime`

0 commit comments

Comments
 (0)