sharp
High-performance Node.js image processing — resize, convert, compress, and transform images using libvips at native speed.
sharp
Node.jsHigh-performance Node.js image processing — resize, convert, compress, and transform images using libvips at native speed.
Fit
Bundle (gzip)
35.0 kB
124.1 kB raw
Install size includes transitive dependencies. Bundle size is gzipped browser payload.
Freshness
The Problem
Processing uploaded images in Node.js (resizing avatars, generating thumbnails, converting formats) with pure JavaScript is slow and memory-intensive. Streams of large image files block the event loop.
What It Does
Sharp wraps libvips, a C image processing library, exposing a chainable API. It processes images via streams without loading the entire file into memory, supports JPEG, PNG, WebP, AVIF, GIF, TIFF, and SVG, and outperforms most alternatives by 4–5x in benchmarks.
Installation
npm install sharp
npm install -D @types/sharpUsage Example
import sharp from 'sharp';
// Resize and convert an uploaded image
await sharp(req.file.buffer)
.resize(800, 600, { fit: 'inside', withoutEnlargement: true })
.webp({ quality: 80 })
.toFile(`uploads/${userId}-avatar.webp`);
// Generate thumbnail
const thumbnail = await sharp(inputPath)
.resize(200, 200, { fit: 'cover' })
.jpeg({ quality: 70 })
.toBuffer();Related packages
Role and attribute based access control (RBAC + ABAC) for Node.js with a fluent, readable API.
bcryptjsNode.jsPure JavaScript bcrypt password hashing — no native dependencies, same API as bcrypt, works anywhere Node.js runs.
bullmqNode.jsPremium message queue and job scheduler for Node.js backed by Redis — reliable background job processing with retries, priorities, and rate limiting.
casbinNode.jsA powerful authorization library that supports RBAC, ABAC, ACL and more via configurable policy models.
dotenvNode.jsLoad environment variables from a `.env` file into `process.env` — the standard way to manage configuration in Node.js apps.