jimp
- Version 2.2.0
- Published
- 4.65 MB
- 32 dependencies
- MIT license
Install
npm i jimpyarn add jimppnpm add jimpOverview
An image processing library written entirely in JavaScript.
Index
Variables
Type Aliases
Variables
variable defaultFormats
const defaultFormats: any[];variable defaultPlugins
const defaultPlugins: ( | { blit<I extends any>(image: I, options: blit.BlitOptions): I } | { blur<I extends any>(image: I, r: number): I; gaussian<I extends any>(image: I, r: number): I; sharpen<I extends any>(image: I, options: blur.SharpenOptions): I; median<I extends any>(image: I, radius: number): I; bilateral<I extends any>(image: I, options?: blur.BilateralOptions): I; } | { roundCorners<I extends any>( image: I, options: border.RoundCornersOptions ): I; border<I extends any>(image: I, options: border.BorderOptions): I; boxShadow<I extends any>(image: I, options?: border.BoxShadowOptions): I; } | { circle<I extends any>(image: I, options?: circle.CircleOptions): I } | { normalize<I extends any>(image: I): I; invert<I extends any>(image: I): I; brightness<I extends any>(image: I, val: number): I; contrast<I extends any>(image: I, val: number): I; exposure<I extends any>(image: I, stops: number): I; vibrance<I extends any>(image: I, amount: number): I; posterize<I extends any>(image: I, n: number): I; greyscale<I extends any>(image: I): I; opacity<I extends any>(image: I, f: number): I; sepia<I extends any>(image: I, amount?: number): I; gradientMap<I extends any>(image: I, options: color.GradientMapOptions): I; fade<I extends any>(image: I, f: number): I; convolution<I extends any>( image: I, options: | number[][] | { kernel: number[][]; edgeHandling?: import('@jimp/types').Edge | undefined; divisor?: number | undefined; bias?: number | undefined; } ): I; opaque<I extends any>(image: I): I; pixelate<I extends any>( image: I, options: | number | { size: number; x?: number | undefined; y?: number | undefined; w?: number | undefined; h?: number | undefined; } ): I; convolute<I extends any>( image: I, options: | number[][] | { kernel: number[][]; x?: number | undefined; y?: number | undefined; w?: number | undefined; h?: number | undefined; divisor?: number | undefined; bias?: number | undefined; preserveAlpha?: boolean | undefined; } ): I; color<I extends any>(image: I, actions: color.ColorAction[]): I; grain<I extends any>(image: I, options?: color.GrainOptions): I; } | { resize<I extends any>(image: I, options: resize.ResizeOptions): I; scale<I extends any>(image: I, options: resize.ScaleOptions): I; scaleToFit<I extends any>(image: I, options: resize.ScaleToFitOptions): I; } | { contain<I extends any>(image: I, options: contain.ContainOptions): I } | { cover<I extends any>(image: I, options: cover.CoverOptions): I; coverRect<I extends any>( image: I, options: cover.CoverRectOptions ): { x: number; y: number; w: number; h: number }; } | { crop<I extends any>(image: I, options: crop.CropOptions): I; autocropRect<I extends any>( image: I, options?: crop.AutocropOptions ): { x: number; y: number; w: number; h: number }; autocrop<I extends any>(image: I, options?: crop.AutocropOptions): I; } | { displace<I extends any>(image: I, options: displace.DisplaceOptions): I } | { dither<I extends any>(image: I, options?: dither.DitherOptions): I } | { drawLine<I extends any>(image: I, options: draw.DrawLineOptions): I; drawRect<I extends any>(image: I, options: draw.DrawRectOptions): I; drawEllipse<I extends any>(image: I, options: draw.DrawEllipseOptions): I; drawPolygon<I extends any>(image: I, options: draw.DrawPolygonOptions): I; drawPath<I extends any>(image: I, options: draw.DrawPathOptions): I; floodFill<I extends any>(image: I, options: draw.FloodFillOptions): I; } | { fisheye<I extends any>(image: I, options?: fisheye.FisheyeOptions): I } | { flip<I extends any>(image: I, options: flip.FlipOptions): I } | { pHash<I extends any>(image: I, options?: hash.PHashOptions): string; hash<I extends any>( image: I, base?: number, options?: hash.PHashOptions ): string; distanceFromHash<I extends any>( image: I, compareHash: string, options?: hash.PHashOptions ): number; blurhash<I extends any>(image: I, options?: hash.BlurhashOptions): string; } | { colorGrade<I extends any>( image: I, lut: any, options?: lut.ColorGradeOptions ): I; } | { mask<I extends any>(image: I, options: mask.MaskOptions): I } | { erode<I extends any>(image: I, options: morphology.MorphologyOptions): I; dilate<I extends any>(image: I, options: morphology.MorphologyOptions): I; open<I extends any>(image: I, options: morphology.MorphologyOptions): I; close<I extends any>(image: I, options: morphology.MorphologyOptions): I; } | { print<I extends any>(image: I, options: any): I } | { rotate<I extends any>(image: I, options: rotate.RotateOptions): I; affine<I extends any>(image: I, options: rotate.AffineOptions): I; skew<I extends any>(image: I, options: rotate.SkewOptions): I; } | { threshold<I extends any>(image: I, options: threshold.ThresholdOptions): I } | { quantize<I extends any>(image: I, options: quantize.QuantizeOptions): I; palette<I extends any>( image: I, count: number, options?: quantize.PaletteOptions ): quantize.PaletteColor[]; dominantColor<I extends any>( image: I, options?: quantize.PaletteOptions ): number | undefined; })[];variable Jimp
const Jimp: { new (options?: any): { bitmap: any; background: number; formats: import('@jimp/types').Format<any>[]; mime?: string; iccProfile?: Buffer; inspect(): string; toString(): string; readonly width: number; readonly height: number; readonly colorSpace: import('@jimp/types').ColorSpaceName | 'custom'; toColorSpace<S extends any>(this: S, colorSpace: any): S; getBuffer<ProvidedMimeType extends unknown, Options extends any>( mime: ProvidedMimeType, options?: Options ): Promise<Buffer<ArrayBufferLike>>; getBase64<ProvidedMimeType extends unknown, Options extends any>( mime: ProvidedMimeType, options?: Options ): Promise<string>; write<Path extends string>(path: Path, options?: any): Promise<void>; clone<S extends any>(this: S): S; apply<S extends any>(this: S, edits: CoreJimpEdit<S>[]): S; getPixelIndex(x: number, y: number, edgeHandling?: any): number; getPixelColor(x: number, y: number): number; setPixelColor<S extends any>(this: S, hex: number, x: number, y: number): S; hasAlpha(): boolean; composite<S extends any>( this: S, src: any, x?: number, y?: number, options?: { mode?: import('@jimp/core').BlendMode; opacitySource?: number; opacityDest?: number; } ): S; scan<S extends any>( this: S, f: (x: number, y: number, idx: number) => any ): S; scan<S extends any>( this: S, x: number, y: number, w: number, h: number, cb: (x: number, y: number, idx: number) => any ): S; scanIterator<S extends any>( this: S, x?: number, y?: number, w?: number, h?: number ): Generator<{ x: number; y: number; idx: number; image: S }, void, unknown>; }; read( url: string | import('@jimp/core').ImageInput, options?: | import('@jimp/core').CreateReadOptions< | Record<'image/bmp', import('@jimp/js-bmp').DecodeBmpOptions> | Record<'image/gif', import('@jimp/js-gif').DecodeGifOptions> | Record<'image/jpeg', import('@jimp/js-jpeg').DecodeJpegOptions> | Record<'image/png', import('@jimp/js-png').DecodePngOptions> | Record<'image/tiff', import('@jimp/js-tiff').DecodeTiffOptions> | Record< 'image/vnd.microsoft.icon', import('@jimp/js-ico').DecodeIcoOptions > | Record<'image/x-icon', import('@jimp/js-ico').DecodeIcoOptions> | Record<'image/x-ms-bmp', import('@jimp/js-bmp').DecodeBmpOptions> > | undefined ): Promise<any>; readFrames( url: string | import('@jimp/core').ImageInput, options?: | import('@jimp/core').CreateReadFramesOptions< | Record<'image/bmp', import('@jimp/js-bmp').DecodeBmpOptions> | Record<'image/gif', import('@jimp/js-gif').DecodeGifOptions> | Record<'image/jpeg', import('@jimp/js-jpeg').DecodeJpegOptions> | Record<'image/png', import('@jimp/js-png').DecodePngOptions> | Record<'image/tiff', import('@jimp/js-tiff').DecodeTiffOptions> | Record< 'image/vnd.microsoft.icon', import('@jimp/js-ico').DecodeIcoOptions > | Record<'image/x-icon', import('@jimp/js-ico').DecodeIcoOptions> | Record<'image/x-ms-bmp', import('@jimp/js-bmp').DecodeBmpOptions> > | undefined ): Promise<any>; fromBufferFrames( buffer: any, options?: | import('@jimp/core').CreateReadFramesOptions< | Record<'image/bmp', import('@jimp/js-bmp').DecodeBmpOptions> | Record<'image/gif', import('@jimp/js-gif').DecodeGifOptions> | Record<'image/jpeg', import('@jimp/js-jpeg').DecodeJpegOptions> | Record<'image/png', import('@jimp/js-png').DecodePngOptions> | Record<'image/tiff', import('@jimp/js-tiff').DecodeTiffOptions> | Record< 'image/vnd.microsoft.icon', import('@jimp/js-ico').DecodeIcoOptions > | Record<'image/x-icon', import('@jimp/js-ico').DecodeIcoOptions> | Record<'image/x-ms-bmp', import('@jimp/js-bmp').DecodeBmpOptions> > | undefined ): Promise<any>; fromBitmap(bitmap: any): any; fromBuffer( buffer: any, options?: | import('@jimp/core').CreateReadOptions< | Record<'image/bmp', import('@jimp/js-bmp').DecodeBmpOptions> | Record<'image/gif', import('@jimp/js-gif').DecodeGifOptions> | Record<'image/jpeg', import('@jimp/js-jpeg').DecodeJpegOptions> | Record<'image/png', import('@jimp/js-png').DecodePngOptions> | Record<'image/tiff', import('@jimp/js-tiff').DecodeTiffOptions> | Record< 'image/vnd.microsoft.icon', import('@jimp/js-ico').DecodeIcoOptions > | Record<'image/x-icon', import('@jimp/js-ico').DecodeIcoOptions> | Record<'image/x-ms-bmp', import('@jimp/js-bmp').DecodeBmpOptions> > | undefined ): Promise<any>; encodeFrames<ProvidedMimeType extends unknown>( mime: ProvidedMimeType, frames: import('@jimp/core').FrameInput[], options?: any ): Promise<Buffer>; writeFrames<Path extends string>( path: Path, frames: import('@jimp/core').FrameInput[], options?: any ): Promise<void>;} & (new (...args: any[]) => any);A
Jimpclass enables you to:class- Read an image into a "bit map" (a collection of pixels) - Modify the bit map through methods that change the pixels - Write the bit map back to an image buffer
Example 1
#### Basic
You can use the Jimp class to make empty images. This is useful for when you want to create an image that composed of other images on top of a background.
import { Jimp } from "jimp";const image = new Jimp({ width: 256, height: 256, color: 0xffffffff });const image2 = new Jimp({ width: 100, height: 100, color: 0xff0000ff });image.composite(image2, 50, 50);#### Node
You can use jimp in Node.js. For example you can read an image from a file and resize it and then write it back to a file.
import { Jimp } from "jimp";import { promises as fs } from "fs";const image = await Jimp.read("test/image.png");image.resize({ w: 256, h: 100 });image.greyscale();await image.write('test/output.png');#### Browser
You can use jimp in the browser by reading files from URLs
import { Jimp } from "jimp";const image = await Jimp.read("https://upload.wikimedia.org/wikipedia/commons/0/01/Bot-Test.jpg");image.resize({ w: 256, h: 100 });image.greyscale();const canvas = document.createElement("canvas");canvas.width = image.bitmap.width;canvas.height = image.bitmap.height;const ctx = canvas.getContext("2d");const imageData = new ImageData(new Uint8ClampedArray(image.bitmap.data),image.bitmap.width,image.bitmap.height);ctx.putImageData(imageData, 0, 0);document.body.appendChild(canvas);
variable JimpMime
const JimpMime: { bmp: 'image/bmp'; gif: 'image/gif'; ico: 'image/x-icon'; jpeg: 'image/jpeg'; png: 'image/png'; tiff: 'image/tiff';};Convenience object for getting the MIME types of the default formats
Type Aliases
type JimpEdit
type JimpEdit = CoreJimpEdit<JimpInstance>;One edit for
image.apply, e.g.["resize", { w: 100 }]
type JimpInstance
type JimpInstance = InstanceType<typeof Jimp>;Package Files (1)
Dependencies (32)
- @jimp/core
- @jimp/diff
- @jimp/js-bmp
- @jimp/js-gif
- @jimp/js-ico
- @jimp/js-jpeg
- @jimp/js-png
- @jimp/js-tiff
- @jimp/plugin-blit
- @jimp/plugin-blur
- @jimp/plugin-border
- @jimp/plugin-circle
- @jimp/plugin-color
- @jimp/plugin-contain
- @jimp/plugin-cover
- @jimp/plugin-crop
- @jimp/plugin-displace
- @jimp/plugin-dither
- @jimp/plugin-draw
- @jimp/plugin-fisheye
- @jimp/plugin-flip
- @jimp/plugin-hash
- @jimp/plugin-lut
- @jimp/plugin-mask
- @jimp/plugin-morphology
- @jimp/plugin-print
- @jimp/plugin-quantize
- @jimp/plugin-resize
- @jimp/plugin-rotate
- @jimp/plugin-threshold
- @jimp/types
- @jimp/utils
Dev Dependencies (29)
- @jimp/config-eslint
- @jimp/config-typescript
- @jimp/config-vitest
- @jimp/test-utils
- @jimp/wasm-avif
- @jimp/wasm-jpeg
- @jimp/wasm-jpeg2000
- @jimp/wasm-jxl
- @jimp/wasm-png
- @jimp/wasm-svg
- @jimp/wasm-webp
- @rollup/plugin-commonjs
- @rollup/plugin-inject
- @rollup/plugin-node-resolve
- @rollup/plugin-terser
- @typescript/typescript6
- @vitest/browser
- buffer
- eslint
- node-self
- path-browserify
- rollup
- rollup-plugin-dts
- rollup-plugin-esbuild
- rollup-plugin-polyfill-node
- tshy
- typescript
- vite-plugin-node-polyfills
- vitest
Peer Dependencies (0)
No peer dependencies.
Badge
To add a badge like this oneto your package's README, use the codes available below.
You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/jimp.
- Markdown[](https://www.jsdocs.io/package/jimp)
- HTML<a href="https://www.jsdocs.io/package/jimp"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>
- Updated .
Package analyzed in 6840 ms. - Missing or incorrect documentation? Open an issue for this package.
