Exapedia / Tools / JavaScript image processing libraries JavaScript image processing libraries Updated Nov 2026
JavaScript image processing libraries decode image files, change their pixels, and encode the results in a new format or size. A processing pipeline reads an image, applies steps such as resizing, cropping, or color reduction, and writes the output. These libraries generate the thumbnails, product photos, and optimized web images that apps serve from upload pipelines and build steps.
Popularity sharp @napi-rs/canvas node-canvas Image Q jimp Pica imagemin skia-canvas FAQ Popularity sharp has the most monthly downloads in this comparison, at 630.3M .
Library Monthly downloads Stars Last release License sharp 630.3M
32.9K Sep 2026 Apache-2.0 @napi-rs/canvas 197.5M
2.4K Nov 2026 MIT node-canvas 43.8M
10.7K Mar 2026 MIT Image Q 17.3M
168 Jan 2022 MIT jimp 16.7M
14.7K Apr 2026 MIT Pica 6.4M
4.2K Aug 2026 MIT imagemin 4.1M
5.7K Mar 2025 MIT skia-canvas 1.1M
2.6K Nov 2026 MIT Downloads: npm , last thirty days. Stars and releases: GitHub. Amber: no release in over a year.
Libraries and code examples Transforms images through a streaming image-processing pipeline.
Downloads / mo 630.3M
Stars 32.9K
Last release 0.35.5
License Apache-2.0 Strengths Converts common web image formats . Read common image formats and produce JPEG, PNG, WebP, GIF, or AVIF. Works with streams and buffers . Process image data from streams, buffers, or file paths. Limitations Repeated resizing replaces earlier settings . Use separate pipelines when the same input needs multiple resize stages. $ npm install sharp Copy
import sharp from 'sharp';
await sharp('input.jpg').resize({width: 320}).toFile('output.webp');
Draws with the Canvas 2D API in Node.js through a Skia binding with no system dependencies.
Downloads / mo 197.5M
Stars 2.4K
Last release 1.1.1
License MIT Strengths No system libraries to install . Prebuilt Skia binaries install without Cairo or other system packages. Limitations Needs a recent glibc on Linux . Older Linux systems fail when their glibc predates the version that Skia requires. $ npm install @napi-rs/canvas Copy
import {writeFile} from 'node:fs/promises';
import {createCanvas} from '@napi-rs/canvas';
const canvas = createCanvas(100, 100);
canvas.getContext('2d').fillRect(10, 10, 50, 50);
await writeFile('output.png', await canvas.encode('png'));
@napi-rs/canvas examples From open-source projects on GitHub fitImageToSquareBox(image: canvas.Image | canvas.Canvas, size: number = 1024) {
// this.logger.debug(`Fitting image(${ image.width }x${ image.height }) to ${ size } box`);
// const t0 = Date.now();
if (image.width <= size && image.height <= size) {
if (image instanceof this.canvas.Canvas) {
return image;
}
const canvasInstance = this.canvas.createCanvas(image.width, image.height);
const ctx = canvasInstance.getContext('2d');
ctx.drawImage(image, 0, 0, image.width, image.height, 0, 0, canvasInstance.width, canvasInstance.height);
// this.logger.debug(`No need to resize, copied to canvas in ${ Date.now() - t0 } ms`);
return canvasInstance;
}
const aspectRatio = image.width / image.height;
const resizedWidth = Math.round(aspectRatio > 1 ? size : size * aspectRatio);
const resizedHeight = Math.round(aspectRatio > 1 ? size / aspectRatio : size);
const canvasInstance = this.canvas.createCanvas(resizedWidth, resizedHeight);
const ctx = canvasInstance.getContext('2d');
ctx.drawImage(image, 0, 0, image.width, image.height, 0, 0, resizedWidth, resizedHeight);
// this.logger.debug(`Resized to ${ resizedWidth }x${ resizedHeight } in ${ Date.now() - t0 } ms`);
return canvasInstance;
}
Show full example Implements the Canvas drawing API for server-side Node.js graphics.
Downloads / mo 43.8M
Stars 10.7K
Last release 3.2.3
License MIT Strengths Uses the familiar Canvas API . Draw through a Canvas 2D context on the server. Supports registered font files . Register a font file before drawing text with that font. Limitations Unsupported platforms require native builds . Install Cairo and Pango when prebuilt binaries are unavailable. Optional codecs affect image support . GIF, SVG, and JPEG support depends on the corresponding native libraries. $ npm install canvas Copy
const {writeFileSync} = require('node:fs');
const {createCanvas} = require('canvas');
const canvas = createCanvas(100, 100);
canvas.getContext('2d').fillRect(10, 10, 50, 50);
writeFileSync('output.png', canvas.toBuffer('image/png'));
node-canvas examples From open-source projects on GitHub private renderChart(configuration: ChartConfiguration): ChartJS {
const canvas = this._createCanvas(this._width, this._height, this._type);
(canvas as any).style = (canvas as any).style || {};
configuration.options = configuration.options || {};
configuration.options.responsive = false;
// Disable animation (otherwise charts will throw exceptions)
configuration.options.animation = false;
const context = canvas.getContext('2d');
(global as any).Image = this._image; // Some plugins use this API
const chart = new this._chartJs((context as any), configuration);
delete (global as any).Image;
return chart;
}
Show full example Reduces an image's colors to a smaller palette, with alpha support and several quantization algorithms.
Downloads / mo 17.3M
Stars 168
Last release 4.0.0
License MIT Strengths Choice of color distance formula . Options select the formula that measures how far apart two colors are. Limitations Works on pixel containers . Images pass in and out as point containers rather than image files. $ npm install image-q Copy
import {utils, buildPaletteSync} from 'image-q';
const pixels = utils.PointContainer.fromUint8Array(new Uint8Array([255, 0, 0, 255, 0, 255, 0, 255]), 2, 1);
const palette = buildPaletteSync([pixels], {colors: 2});
console.log(palette);
Image Q examples From open-source projects on GitHub quantize<I extends JimpClass>(image: I, options: QuantizeOptions) {
const {
colors,
colorDistanceFormula,
paletteQuantization,
imageQuantization,
} = QuantizeOptionsSchema.parse(options);
const inPointContainer = utils.PointContainer.fromUint8Array(
new Uint8Array(image.bitmap.data.buffer),
image.bitmap.width,
image.bitmap.height
);
const palette = buildPaletteSync([inPointContainer], {
colors,
colorDistanceFormula,
paletteQuantization,
});
const outPointContainer = applyPaletteSync(inPointContainer, palette, {
colorDistanceFormula,
imageQuantization,
});
image.bitmap.data = Buffer.from(outPointContainer.toUint8Array());
return image;
}
Show full example Loads and edits images in JavaScript for Node.js and browsers.
Downloads / mo 16.7M
Stars 14.7K
Last release 1.6.1
License MIT Strengths Avoids native image dependencies . Use JavaScript image codecs in Node.js or browser environments. Includes bitmap-font text drawing . Load a bitmap font and print text into an image. Limitations Large images increase memory use . JavaScript codecs allocate substantial memory and prioritize portability over performance. Version upgrades change method arguments . Migrate positional image operations to v1 options objects. $ npm install jimp Copy
import {Jimp} from 'jimp';
const image = await Jimp.read('input.png');
image.resize({w: 320});
await image.write('output.png');
jimp examples From open-source projects on GitHub export const generateProfilePicture = async (
mediaUpload: WAMediaUpload,
dimensions?: { width: number; height: number }
) => {
let buffer: Buffer
const { width: w = 640, height: h = 640 } = dimensions || {}
if (Buffer.isBuffer(mediaUpload)) {
buffer = mediaUpload
} else {
// Use getStream to handle all WAMediaUpload types (Buffer, Stream, URL)
const { stream } = await getStream(mediaUpload)
// Convert the resulting stream to a buffer
buffer = await toBuffer(stream)
}
const lib = await getImageProcessingLibrary()
let img: Promise<Buffer>
if ('sharp' in lib && typeof lib.sharp?.default === 'function') {
img = lib.sharp
.default(buffer)
.resize(w, h)
.jpeg({
quality: 50
})
.toBuffer()
} else if ('jimp' in lib && typeof lib.jimp?.Jimp === 'function') {
const jimp = await (lib.jimp.Jimp as any).read(buffer)
const min = Math.min(jimp.width, jimp.height)
const cropped = jimp.crop({ x: 0, y: 0, w: min, h: min })
img = cropped.resize({ w, h, mode: lib.jimp.ResizeStrategy.BILINEAR }).getBuffer('image/jpeg', { quality: 50 })
} else {
throw new Boom('No image processing library available')
}
return {
img: await img
}
}
Show full example Resizes images in the browser without pixelation.
Downloads / mo 6.4M
Stars 4.2K
Last release 10.0.3
License MIT Strengths Shrinks images before upload . Resizing in the browser reduces the upload size of large images. Limitations Remote images need CORS headers . Images from another domain load only with an Access-Control-Allow-Origin header. $ npm install pica Copy
import pica from 'pica';
const source = new Image();
source.src = 'input.jpg';
await source.decode();
const target = document.createElement('canvas');
target.width = 100;
target.height = 100;
await pica().resize(source, target);
document.body.append(target);
Pica examples From open-source projects on GitHub async _transform (env: ImageBlobReduceEnv): Promise<ImageBlobReduceEnv> {
env.out_canvas = this.pica.createCanvas(env.transform_width!, env.transform_height!)
// Dim temporary env vars to prevent use and avoid confusion when orientation
// changes. Take the real size from the canvas.
env.transform_width = null
env.transform_height = null
const { max, ...pica_opts } = env.opts
await this.pica.resize(env.image!, env.out_canvas, pica_opts)
return env
}
Show full example Minifies image files through optimizer plugins.
Downloads / mo 4.1M
Stars 5.7K
Last release 9.0.1
License MIT Strengths Optimizes in-memory image data . The buffer method optimizes image data that is already in memory. Limitations Writes files only with a destination . Results stay in memory unless the destination option names a folder. $ npm install imagemin imagemin-jpegtran Copy
import imagemin from 'imagemin';
import imageminJpegtran from 'imagemin-jpegtran';
const files = await imagemin(['images/*.jpg'], {destination: 'build/images', plugins: [imageminJpegtran()]});
console.log(files);
imagemin examples From open-source projects on GitHub async function processFile(filePath: string, buffer: Buffer) {
let content: Buffer
try {
content = await imagemin.buffer(buffer, {
plugins: getImageminPlugins(options),
})
const size = content.byteLength,
oldSize = buffer.byteLength
tinyMap.set(filePath, {
size: size / 1024,
oldSize: oldSize / 1024,
ratio: size / oldSize - 1,
})
return content
} catch (error) {
config.logger.error('imagemin error:' + filePath)
}
}
Show full example Renders the Canvas API in Node.js through Skia and exports vector or bitmap images.
Downloads / mo 1.1M
Stars 2.6K
Last release 4.0.1
License MIT Strengths Vector and bitmap output . A canvas saves as a PDF, SVG, JPEG, PNG, or WEBP file. Multi-page PDF output . Several pages on one canvas export as one PDF or as a sequence of image files. $ npm install skia-canvas Copy
import {Canvas} from 'skia-canvas';
const canvas = new Canvas(100, 100);
canvas.getContext('2d').fillRect(10, 10, 50, 50);
await canvas.toFile('output.png');
skia-canvas examples From open-source projects on GitHub function drawTextElement(
image: Image,
ctx: OffscreenCanvasRenderingContext2D | SkiaCanvasRenderingContext2D,
text: DrawTextLabel,
defaultFont: string,
defaultColor: number[],
) {
ctx.font = text.font ?? defaultFont;
const fontColor = text.fontColor ?? defaultColor;
validateValues(fontColor, image);
const alpha = fontColor[3] ? fontColor[3] / 255 : 1;
const normalizedColor = [
fontColor[0] ?? 0,
fontColor[1] ?? 0,
fontColor[2] ?? 0,
alpha,
];
ctx.fillStyle = `rgba(${normalizedColor.join(',')})`;
ctx.fillText(String(text.content), text.position.column, text.position.row);
}
Show full example For coding agents
Found your image processing library? Help your agent use it. Connect Exa so your coding agent can find the library’s documentation, check its API, and look up implementations while you build.
Claude Code Cursor Codex VS Code Devin Devin Desktop Gemini CLI OpenCode
Run in your terminal
claude plugin install exa@claude-plugins-official Copy Add to ~/.cursor/mcp.json
{
"mcpServers": {
"exa": {
"url": "https://mcp.exa.ai/mcp"
}
}
} Copy Open in your browser, then install the Exa plugin
https://chatgpt.com/plugins/exa Copy Add to .vscode/mcp.json
{
"servers": {
"exa": {
"type": "http",
"url": "https://mcp.exa.ai/mcp"
}
}
} Copy In Devin, open Customize, then MCPs, and add a custom HTTP server with this URL
https://mcp.exa.ai/mcp Copy Add to ~/.config/devin/mcp_config.json
{
"mcpServers": {
"exa": {
"serverUrl": "https://mcp.exa.ai/mcp"
}
}
} Copy Add to ~/.gemini/settings.json
{
"mcpServers": {
"exa": {
"httpUrl": "https://mcp.exa.ai/mcp"
}
}
} Copy Add to opencode.json
{
"mcp": {
"exa": {
"type": "remote",
"url": "https://mcp.exa.ai/mcp"
}
}
} Copy