# Sharp — card for AI agents

High-speed image processing for resizing, converting JPEG, PNG, WebP, GIF formats.

Category: Files, images and media · npm package `sharp` · latest version 0.35.5 (checked 2026-11-01)
Install: `npm install sharp`
License: Apache-2.0 (permissive)

In your own product (generator, app, hosted service): **yes**. Permissive license: ship it inside your own product, closed or open source, and keep its license and copyright notice.

## Rules for AI agents (paste into AGENTS.md or CLAUDE.md)

## Sharp
- Install with `npm install sharp`. Import with `import sharp from 'sharp'` (ESM) or `const sharp = require('sharp')` (CJS).
- Target a runtime with Node-API v9 support: Node.js >= 20.9.0, Deno or Bun.
- Chain operations on `sharp(input)` and finish with `.toBuffer()` or `.toFile()`. Input can be a file path, a Buffer or a Stream.
- For smaller JPEG output, use `.jpeg({ mozjpeg: true })` as the README shows. Do not add a separate imagemin step for this.
- When using more than 4 physical CPU cores, set `UV_THREADPOOL_SIZE` before the Node.js process starts.
- With the default glibc allocator on Linux, set `MALLOC_ARENA_MAX` to 2 or 4 before the process starts. Use `sharp.concurrency()` to manage threads per image.

## Agent Skills for it
- sharp-edges from trailofbits/skills: `npx skills add trailofbits/skills --skill sharp-edges`

## What it is
- Sharp is an image processing module for JavaScript, installed with `npm install sharp` and licensed Apache-2.0. The README gives its "typical use case": converting large images in common formats to smaller, web-friendly JPEG, PNG, WebP, GIF and AVIF images of varying dimensions. It also does rotation, extraction, compositing and gamma correction.
- It is a Node-API module. It runs on runtimes with Node-API v9 support, including Node.js (>= 20.9.0), Deno and Bun. The image work is done by libvips. The site describes libvips as a library "originally created in 1989 at Birkbeck College" and maintained by a small team led by John Cupitt. Sharp reads JPEG, PNG, WebP, GIF, AVIF, TIFF and SVG. It writes JPEG, PNG, WebP, GIF, AVIF and TIFF, plus raw pixel data. Input and output can each be a file, a Buffer or a Stream.
- The GitHub repository was created on 2013-08-19. The latest listed release is v0.35.5, published 2026-09-27.

## Caveats
- Four images in parallel unless you change the env var: How many images sharp processes in parallel is set by libuv's `UV_THREADPOOL_SIZE`, which defaults to 4. For more than 4 physical CPU cores, the docs say to set it before the Node.js process starts.
- One thread per image on default glibc Linux: On glibc-based Linux without jemalloc or without `MALLOC_ARENA_MAX`, libvips defaults to 1 thread per image "to help reduce memory fragmentation". On other systems, the default thread count matches the number of CPU cores.
- Benchmark rivals are retired projects: The benchmark's own contender list describes the imagemagick package as one that "has been unmaintained for a long time". It says gm "has been sunset".
- SVG off by default in StackBlitz's WebAssembly port: StackBlitz's August 2023 post says SVG support was disabled by default in its WebAssembly build. The post says "Text is hard". The team preferred disabling the feature to rendering images with text quietly missing.

## Numbers (AgentGid data)
- Gid Score: 84.0 (#48 of all tools, 2 of 281 in its category)
- Used in 297 public projects set up for AI coding agents (4.7%)
- Downloads last week: 171,932,863 (as of 2026-11-24), +45.1% over 4 weeks
- GitHub stars: 32,869 (as of 2026-11-24)
- Last push: 2026-11-24

## Often used with
TypeScript 91.9%, Tailwind CSS 67.3%, Playwright (JavaScript) 49.2%, tsx 45.5%, Vitest 52.9%, React 64.0%

## Links
- AgentGid page: https://agentgid.com/tools/sharp/
- Homepage: https://sharp.pixelplumbing.com
- Repository: https://github.com/lovell/sharp
- Source: https://github.com/lovell/sharp#readme
- Source: https://github.com/lovell/sharp
- Source: https://github.com/lovell/sharp/releases
- Source: https://sharp.pixelplumbing.com
- Source: https://sharp.pixelplumbing.com/performance


## sharp: resize and convert images on your server

sharp is a free JavaScript package that makes photos smaller and faster to load. Your server or build step resizes uploads, crops avatars and turns big JPEG or PNG files into WebP or AVIF. It runs in Node.js, Deno or Bun, not in the web page itself.

### Where to use it
- Thumbnails for uploaded photos: A user uploads a 6 MB phone photo; your server saves a small, upright copy for lists and previews.
- Serve WebP or AVIF instead of JPEG: Your site's images load faster because the build or server saves them in newer, smaller formats.
- Square profile pictures: Any photo a user picks becomes a 200 by 200 avatar, cropped around the busiest part of the picture.
- Never upscale small images: Fit pictures into a 200 pixel box for a gallery, but leave small ones at their own size so they do not blur.
- Accept only JPEG uploads: Your upload service refuses every other image format before decoding, which shrinks the risk from crafted files.
- Share images from a template: Turn a drawing made from a template, such as a post title card, into a PNG picture for social media previews. (idea, not from the official pages)

### How to start
- Add sharp to your project. The right ready-built files for your system come with it, so your package manager must install optional packages.

```
npm install sharp
```

- Import it (ES modules or require both work).

```
// ESM
import sharp from 'sharp';

// CJS
const sharp = require('sharp');
```


### License
sharp itself is free under the Apache-2.0 license, also in paid products. The ready-built image engine it installs (libvips) is under LGPL-3.0-or-later, which matters if you ship it inside a desktop app.

### Good to know
- It needs Node.js 20.9 or newer (or Deno or Bun); version 0.35 dropped Node.js 18.
- It does not run in the web browser; resize images on the server or during the build.
- Saved images lose their camera data, including the flag that says which way is up; call autoOrient() first.
- Ready-built files exist for common Mac, Windows and Linux systems; a server with a different system needs files for that system.
- The project is active; version 0.35.5 came out on 27 September 2026.

Checked 2026-11-11 against: https://sharp.pixelplumbing.com/, https://sharp.pixelplumbing.com/install/, https://sharp.pixelplumbing.com/api-constructor/, https://sharp.pixelplumbing.com/api-resize/, https://sharp.pixelplumbing.com/api-output/, https://sharp.pixelplumbing.com/security/, https://sharp.pixelplumbing.com/changelog/v0.35.0/, https://github.com/lovell/sharp/blob/main/README.md, https://github.com/lovell/sharp/blob/main/LICENSE, https://registry.npmjs.org/sharp, https://registry.npmjs.org/@img/sharp-libvips-linux-x64/latest

### Mistakes to avoid
- Don't: npm install sharp on Node.js 18 → Do: Upgrade to Node.js 20.9+ (or pin sharp 0.34 on Node.js 18) (sharp 0.35 dropped Node.js 18.)
- Don't: Running npm install on a Mac and uploading node_modules to a Linux server or AWS Lambda → Do: Install for the target, e.g. npm install --cpu=x64 --os=linux --libc=glibc sharp, or install on the server itself (Package managers pick the ready-built files for the machine that runs the install.)
- Don't: Letting webpack or esbuild bundle sharp into server code → Do: Mark sharp as external (webpack externals, esbuild --external:sharp) (sharp loads native files at run time and must stay in node_modules.)
- Don't: sharp(input).resize(800).toFile('out.jpg') on phone photos → Do: sharp(input).autoOrient().resize(800).toFile('out.jpg') (Output strips EXIF orientation, so photos taken sideways stay sideways.)
- Don't: sharp(input, { failOnError: false }) → Do: sharp(input, { failOn: 'none' }), only for trusted input (The failOnError option was removed in 0.35; failOn controls how strict decoding is.)

### Questions
- Can I use sharp in the browser or in a React component? No. Run it on your server, in a serverless function or in your build; the docs say browser use is unsupported.
- Which image formats can it read and write? It reads JPEG, PNG, WebP, GIF, AVIF, TIFF and SVG, and writes JPEG, PNG, WebP, GIF, AVIF and TIFF.
- Why do my phone photos come out sideways? Output drops the camera orientation data. Call autoOrient() before resizing.
- Does it work on AWS Lambda? Yes, if your deployment package holds the Linux build for the function's chip type.
- Is it safe for images uploaded by strangers? It treats all input as untrusted, rejects files with decode warnings and limits the pixel count by default.

---
AgentGid's catalog is curated: every entry was checked against the maker's official pages (registry, repository, license and pricing pages) on the date shown; a license value shows the quote it stands on wherever AgentGid has one. Usage numbers come from AgentGid's own scan of public repositories set up for AI coding agents. Claims by makers are reported, not tested by AgentGid.
