Jimp
Pure JavaScript image processing library with no native dependencies for resize, crop and effects.
Official Documentation ↗jimp v1.x(原 v0.x)/ Node 18 LTS(纯 JavaScript). Check the official docs for the latest API surface.Installation
npm install jimppnpm add jimpyarn add jimpMethods
No methods match this filter.
Overview
Jimp offers image manipulation in pure JavaScript, avoiding native compilation. It supports reading, resizing, cropping, compositing and a range of color operations, at the cost of speed relative to native libraries.
Core Methods
Load an image with Jimp.read, chain transforms such as resize, crop, greyscale and blur, then write the result. Pixel access lets you implement custom effects when built-ins are not enough.
Usage Notes
Use Jimp where a native toolchain is undesirable, and keep images modest in size. Reuse loaded images across operations and write once rather than encoding repeatedly.
Common Pitfalls
Whole-image loading means memory scales with dimensions, so huge images can crash the process. The version 1 API changed several method signatures, so check the version when copying examples. Some advanced formats are read-only or unsupported.
FAQ
- Why choose Jimp over sharp?
- Jimp runs in pure JavaScript with no native build step, which simplifies deployment on unusual platforms. It is slower and uses more memory than sharp for large images, so pick based on constraints.
- Which formats are supported?
- Jimp supports common formats such as PNG, JPEG, BMP and GIF depending on the version. Check the plugin list for the format you need before relying on it in production.
- How do I process many images efficiently?
- Jimp loads whole images into memory, so process images sequentially or with a small concurrency limit and release references. Parallel decoding of many large images can exhaust memory.
Report a problem with this API docOpens a pre-filled issue on GitHub.