# Jimp — Pure JavaScript Image Processing for Node.js > An image processing library written entirely in JavaScript with zero native dependencies, supporting resize, crop, color manipulation, and format conversion. ## Install Save in your project root: # Jimp — Pure JavaScript Image Processing for Node.js ## Quick Use ```bash npm install jimp ``` ```js import Jimp from 'jimp'; const image = await Jimp.read('photo.png'); image.resize(256, 256).greyscale().write('thumbnail.png'); ``` ## Introduction Jimp (JavaScript Image Manipulation Program) is a pure-JavaScript image processing library for Node.js that requires no native addons like libvips or ImageMagick. It reads, manipulates, and writes images using only JavaScript, making it easy to deploy in constrained environments like serverless functions and Docker scratch containers. ## What Jimp Does - Reads and writes PNG, JPEG, BMP, TIFF, and GIF (first frame) images - Resizes with multiple interpolation algorithms (bilinear, bicubic, nearest-neighbor, Hermite) - Applies color transformations: brightness, contrast, saturation, hue rotation, greyscale, sepia - Composites images with alpha blending, masks, and per-pixel operations - Draws text using bitmap fonts (BMFont format) without system font dependencies ## Architecture Overview Jimp represents images as flat RGBA pixel buffers backed by standard ArrayBuffers. Each manipulation method iterates over the buffer in-place or produces a new buffer, using pure-JavaScript codecs for format decoding and encoding. The plugin architecture allows extending Jimp with custom operations registered via `Jimp.prototype`. Because there are no native bindings, Jimp runs identically across all platforms Node.js supports. ## Self-Hosting & Configuration - Install from npm — no build step, no native compilation, no system libraries needed - Chain operations fluently: `image.resize(w, h).rotate(90).quality(80).write(path)` - Use `Jimp.AUTO` for width or height to maintain aspect ratio during resize - Load images from file paths, URLs, or Buffers - Export to Buffer for streaming to S3, HTTP responses, or other services without temp files ## Key Features - Zero native dependencies — deploys without libvips, sharp, or ImageMagick - Works in AWS Lambda, Vercel Functions, and other read-only filesystem environments - Pixel-level access via `image.scan()` for custom filters and analysis - Built-in hash functions (pHash, average hash) for duplicate image detection - Over 14,600 GitHub stars and 5 million weekly npm downloads ## Comparison with Similar Tools - **sharp** — much faster (uses libvips C library); Jimp trades speed for zero native deps and portability - **ImageMagick/GraphicsMagick** — CLI tools with Node bindings; Jimp needs no system packages installed - **canvas (node-canvas)** — Cairo-based 2D drawing; Jimp is focused on image manipulation not rendering - **Pillow (Python)** — Python image library; Jimp is the Node.js pure-JS equivalent - **Squoosh** — browser WASM codecs; Jimp is Node-native and requires no WASM runtime ## FAQ **Q: Is Jimp fast enough for production image processing?** A: For low-volume tasks (thumbnails, avatars, watermarks) it is fine. For high-throughput pipelines processing thousands of images per minute, sharp is a better choice due to native performance. **Q: Can I use Jimp in the browser?** A: The core library targets Node.js, but community forks like jimp/browser offer limited browser support via Webpack/Rollup bundling. **Q: Does it support animated GIFs?** A: Jimp reads only the first frame of animated GIFs. For full animation support, consider libraries like gif-encoder or sharp. **Q: How do I add text to images without system fonts?** A: Jimp uses BMFont bitmap fonts. Load a .fnt file with `Jimp.loadFont()` and render text with `image.print()`. Pre-built fonts are included for common sizes. ## Sources - https://github.com/jimp-dev/jimp - https://jimp-dev.github.io/jimp/ --- Source: https://tokrepo.com/en/workflows/asset-0b52787e Author: AI Open Source