{
 "kind": "tool",
 "slug": "sharp",
 "path": "tools/sharp/",
 "name": "Sharp",
 "maker": null,
 "density": "full",
 "crumbs": [
  [
   "Tools",
   "tools/"
  ],
  [
   "Files, images and media",
   "tools/files-media/"
  ]
 ],
 "lead": "Resize and convert images on your server.",
 "chips": [
  {
   "label": "Files, images and media",
   "path": "tools/files-media/"
  },
  {
   "label": "NPM"
  }
 ],
 "primary": {
  "label": "Copy install command",
  "copy": "npm install sharp"
 },
 "links": [
  {
   "label": "GitHub",
   "href": "https://github.com/lovell/sharp"
  },
  {
   "label": "Website",
   "href": "https://sharp.pixelplumbing.com"
  }
 ],
 "track": "New versions, deprecation and license changes on your dashboard",
 "verdicts": [
  {
   "key": "license",
   "label": "License",
   "value": "Apache-2.0",
   "status": "yes",
   "sub": "Use it in paid apps",
   "quote": "Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license",
   "note": "sharp's own code is Apache-2.0 and free for paid products; using it on your server ships nothing to users.",
   "src": "https://github.com/lovell/sharp/blob/main/LICENSE"
  },
  {
   "key": "maint",
   "label": "Maintained",
   "value": "Maintained",
   "status": "yes",
   "sub": "Last change Nov 24, 2026",
   "note": "Latest GitHub release Sep 27, 2026. ",
   "src": "https://github.com/lovell/sharp"
  },
  {
   "key": "pop",
   "label": "Used by agents' projects",
   "value": "297 projects",
   "status": "info",
   "sub": "#1 of 281 in its category",
   "note": "Dependency in 297 public GitHub projects set up for AI coding agents that we scanned (4.7%).",
   "src": null
  },
  {
   "key": "agent",
   "label": "Agent access",
   "value": "Community skills",
   "status": "info",
   "sub": "1 skills by others",
   "note": "Agent skills for this library in the skills catalog; community skills are written by others, read them before you install.",
   "src": null
  }
 ],
 "vfoot": "From the package registry and GitHub, checked daily; card checked Nov 11, 2026.",
 "blocks": [
  {
   "id": "overview",
   "nav": "Overview",
   "h2": "What Sharp does",
   "parts": [
    {
     "t": "prose",
     "text": "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."
    },
    {
     "t": "h3",
     "text": "What people build with it"
    },
    {
     "t": "uses",
     "items": [
      {
       "title": "Thumbnails for uploaded photos",
       "text": "A user uploads a 6 MB phone photo; your server saves a small, upright copy for lists and previews.",
       "idea": false
      },
      {
       "title": "Serve WebP or AVIF instead of JPEG",
       "text": "Your site's images load faster because the build or server saves them in newer, smaller formats.",
       "idea": false
      },
      {
       "title": "Square profile pictures",
       "text": "Any photo a user picks becomes a 200 by 200 avatar, cropped around the busiest part of the picture.",
       "idea": false
      },
      {
       "title": "Never upscale small images",
       "text": "Fit pictures into a 200 pixel box for a gallery, but leave small ones at their own size so they do not blur.",
       "idea": false
      },
      {
       "title": "Accept only JPEG uploads",
       "text": "Your upload service refuses every other image format before decoding, which shrinks the risk from crafted files.",
       "idea": false
      },
      {
       "title": "Share images from a template",
       "text": "Turn a drawing made from a template, such as a post title card, into a PNG picture for social media previews.",
       "idea": true
      }
     ]
    }
   ]
  },
  {
   "id": "popularity",
   "nav": "Popularity",
   "h2": "Sharp popularity",
   "parts": [
    {
     "t": "stats",
     "items": [
      {
       "n": "84",
       "of": "/ 100",
       "l": "Gid Score, #48 overall"
      },
      {
       "n": "172M",
       "l": "downloads a week, npm"
      },
      {
       "n": "32.9K",
       "l": "GitHub stars"
      },
      {
       "n": "297",
       "l": "agent projects use it"
      }
     ]
    },
    {
     "t": "small",
     "text": "Gid Score measures public popularity and activity, not quality.",
     "link": "How the Gid Score is calculated",
     "path": "tools/top/"
    }
   ]
  },
  {
   "id": "usage",
   "nav": "How it is used",
   "h2": "How Sharp is used",
   "parts": [
    {
     "t": "list",
     "items": [
      "Sharp is a dependency in 297 of the 6,258 public GitHub projects set up for AI coding agents that we scanned (6.1% of the 4,867 JavaScript/TypeScript ones), #1 of 281 in files, images and media.",
      "Counting the projects our scan samples by dependency (Solana 3,067, Ethereum and EVM 1,774, 3D and games 3,130, agent frameworks and SDKs 13,750), it appears in 889; those are left out of every share on this page.",
      "Projects that use it most often also use TypeScript (91.9%), Tailwind CSS (67.3%), Playwright (JavaScript) (49.2%).",
      "It is more common in projects set up for OpenClaw (11.1%) than for Cursor (4.3%)."
     ]
    },
    {
     "t": "h3",
     "text": "By coding agent"
    },
    {
     "t": "rows",
     "rows": [
      {
       "l": "189 projects, 5.8%",
       "v": "Claude Code",
       "path": "agents/claude-code/"
      },
      {
       "l": "134 projects, 4.4%",
       "v": "GitHub Copilot",
       "path": "agents/github-copilot/"
      },
      {
       "l": "106 projects, 4.3%",
       "v": "Cursor",
       "path": "agents/cursor/"
      },
      {
       "l": "39 projects, 8.2%",
       "v": "Gemini CLI",
       "path": "agents/gemini-cli/"
      },
      {
       "l": "37 projects, 11.1%",
       "v": "OpenClaw",
       "path": "agents/openclaw/"
      },
      {
       "l": "26 projects, 5.5%",
       "v": "OpenAI Codex",
       "path": "agents/openai-codex/"
      },
      {
       "l": "17 projects, 5.0%",
       "v": "OpenCode",
       "path": "agents/opencode/"
      },
      {
       "l": "14 projects, 5.0%",
       "v": "Devin Desktop",
       "path": "agents/devin-desktop/"
      }
     ]
    },
    {
     "t": "h3",
     "text": "Often used with"
    },
    {
     "t": "rows",
     "rows": [
      {
       "l": "In 91.9% of its projects",
       "v": "TypeScript",
       "path": "tools/typescript/"
      },
      {
       "l": "In 67.3% of its projects",
       "v": "Tailwind CSS",
       "path": "tools/tailwindcss/"
      },
      {
       "l": "In 49.2% of its projects",
       "v": "Playwright (JavaScript)",
       "path": "tools/playwright-test/"
      },
      {
       "l": "In 45.5% of its projects",
       "v": "tsx",
       "path": "tools/tsx/"
      },
      {
       "l": "In 52.9% of its projects",
       "v": "Vitest",
       "path": "tools/vitest/"
      },
      {
       "l": "In 64.0% of its projects",
       "v": "React",
       "path": "tools/react/"
      },
      {
       "l": "In 55.9% of its projects",
       "v": "Zod",
       "path": "tools/zod/"
      },
      {
       "l": "In 48.8% of its projects",
       "v": "Lucide React",
       "path": "tools/lucide-react/"
      }
     ]
    }
   ]
  },
  {
   "id": "profile",
   "nav": "Profile",
   "h2": "Sharp in practice",
   "parts": [
    {
     "t": "h3",
     "text": "Strengths"
    },
    {
     "t": "rows",
     "rows": [
      {
       "l": "Far ahead on JPEG in the maintainers' benchmark, less so on PNG",
       "v": "The performance page tested sharp v0.35.0 on a 4-core AWS AMD64 machine. On a JPEG decode, resize and encode, sharp (buffer) did 89.63 ops/sec. jimp did 3.44, imagemagick 16.23 and gm 20.92. The PNG gap is smaller: sharp did 47.74 ops/sec against 10.37 for imagemagick, which works out to 4.6x. The docs note that libvips caching was disabled for sharp in this test, and that caching is on by default."
      },
      {
       "l": "Small regions in memory, all cores busy",
       "v": "The site says libvips keeps only small regions of uncompressed image data in memory and processes them a piece at a time. It says this makes full use of multiple CPU cores and the L1/L2/L3 cache."
      },
      {
       "l": "No child processes, no blocked event loop",
       "v": "The site says the work stays non-blocking through libuv, and no child processes are spawned. Promises and <code>async</code>/<code>await</code> are supported."
      },
      {
       "l": "File-size optimisation without extra CLI tools",
       "v": "According to the site, mozjpeg and pngquant features can be used on JPEG and PNG output without invoking separate imagemin processes. It also says JPEG Huffman tables are optimised without jpegoptim or jpegtran, and animated GIF output is optimised without tools such as gifsicle."
      }
     ]
    },
    {
     "t": "h3",
     "text": "Watch out for"
    },
    {
     "t": "rows",
     "rows": [
      {
       "l": "Four images in parallel unless you change the env var",
       "v": "How many images sharp processes in parallel is set by libuv's <code>UV_THREADPOOL_SIZE</code>, which defaults to 4. For more than 4 physical CPU cores, the docs say to set it before the Node.js process starts."
      },
      {
       "l": "One thread per image on default glibc Linux",
       "v": "On glibc-based Linux without jemalloc or without <code>MALLOC_ARENA_MAX</code>, 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."
      },
      {
       "l": "Benchmark rivals are retired projects",
       "v": "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\"."
      }
     ]
    },
    {
     "t": "h3",
     "text": "Auto-orient, resize and encode JPEG with mozjpeg"
    },
    {
     "t": "tabs",
     "label": "Example",
     "items": [
      {
       "tab": "Javascript",
       "code": "// ESM\nimport sharp from 'sharp';\n\nconst output = await sharp('input.jpg')\n  .autoOrient()\n  .resize({ width: 200 })\n  .jpeg({ mozjpeg: true })\n  .toBuffer();"
      }
     ]
    }
   ]
  },
  {
   "id": "more",
   "nav": null,
   "spy_as": "profile",
   "h2": "More about Sharp",
   "parts": [
    {
     "t": "more",
     "items": [
      {
       "title": "Funding",
       "path": "tools/funding/",
       "items": [
        "GitHub Sponsors: https://github.com/lovell",
        "GitHub Sponsors: https://github.com/libvips",
        "Open Collective: https://opencollective.com/libvips",
        "thanks.dev: https://thanks.dev/u/gh/lovell",
        "2 GitHub sponsors"
       ]
      },
      {
       "title": "Agent Skills for it",
       "path": "skills/",
       "items": [
        "sharp-edges: Identifies error-prone APIs, dangerous configurations, and footgun designs that enable security mistakes. Use when reviewing API designs, co"
       ]
      },
      {
       "title": "Packages around it",
       "items": [
        "typescript: Typed JavaScript",
        "@playwright/test: Browser end-to-end tests",
        "tailwindcss: Utility-first CSS",
        "vitest: Unit test runner",
        "tsx: Run TypeScript in Node",
        "react: UI library"
       ]
      },
      {
       "title": "More in Files, images and media",
       "path": "tools/files-media/",
       "items": [
        {
         "text": "Pillow",
         "path": "tools/pillow/"
        },
        {
         "text": "Nodemailer",
         "path": "tools/nodemailer/"
        },
        {
         "text": "jsPDF",
         "path": "tools/jspdf/"
        },
        {
         "text": "SheetJS",
         "path": "tools/xlsx/"
        },
        {
         "text": "qrcode (JavaScript)",
         "path": "tools/qrcode-npm/"
        },
        {
         "text": "JSZip",
         "path": "tools/jszip/"
        },
        {
         "text": "PDF.js",
         "path": "tools/pdfjs-dist/"
        },
        {
         "text": "openpyxl",
         "path": "tools/openpyxl/"
        }
       ]
      }
     ]
    }
   ]
  },
  {
   "id": "alternatives",
   "nav": "Alternatives",
   "h2": "Alternatives",
   "parts": [
    {
     "t": "alts",
     "items": [
      {
       "name": "Sharp",
       "me": true,
       "facts": [
        "Apache-2.0",
        "Gid 84",
        "172M/wk"
       ]
      },
      {
       "name": "Jimp",
       "why": "Pick Jimp when you cannot install native parts (some hosts and sandboxes); it is written entirely in JavaScript.",
       "path": "tools/jimp/",
       "facts": []
      },
      {
       "name": "Pillow",
       "why": "Pick Pillow when your backend is in Python.",
       "path": "tools/pillow/",
       "facts": []
      },
      {
       "name": "Cloudinary",
       "why": "Pick Cloudinary when you would rather upload images to a hosted service that resizes and serves them for you.",
       "path": "tools/cloudinary-npm/",
       "facts": []
      }
     ],
     "more": "Compare Sharp with another tool",
     "more_path": "tools/compare/"
    }
   ]
  },
  {
   "id": "start",
   "nav": "Get started",
   "h2": "Get started",
   "parts": [
    {
     "t": "prompt",
     "text": "Use sharp 0.35.5 (Node.js 20.9+) on the server to auto-orient each uploaded image, resize it to fit 1200 px without enlarging, save WebP plus a 200 px square cover-cropped thumbnail, and set limitInputPixels; keep sharp out of the client bundle."
    },
    {
     "t": "steps",
     "items": [
      {
       "text": "Add sharp to your project. The right ready-built files for your system come with it, so your package manager must install optional packages.",
       "code": "npm install sharp",
       "src": "https://sharp.pixelplumbing.com/install/"
      },
      {
       "text": "Import it (ES modules or require both work).",
       "code": "// ESM\nimport sharp from 'sharp';\n\n// CJS\nconst sharp = require('sharp');\n",
       "src": "https://github.com/lovell/sharp/blob/main/README.md"
      }
     ]
    },
    {
     "t": "h3",
     "text": "Rules for your agent"
    },
    {
     "t": "rules",
     "label": "Paste into AGENTS.md or CLAUDE.md",
     "text": "## Sharp\n- Install with `npm install sharp`. Import with `import sharp from 'sharp'` (ESM) or `const sharp = require('sharp')` (CJS).\n- Target a runtime with Node-API v9 support: Node.js >= 20.9.0, Deno or Bun.\n- Chain operations on `sharp(input)` and finish with `.toBuffer()` or `.toFile()`. Input can be a file path, a Buffer or a Stream.\n- For smaller JPEG output, use `.jpeg({ mozjpeg: true })` as the README shows. Do not add a separate imagemin step for this.\n- When using more than 4 physical CPU cores, set `UV_THREADPOOL_SIZE` before the Node.js process starts.\n- 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.\n"
    },
    {
     "t": "h3",
     "text": "Mistakes to avoid"
    },
    {
     "t": "mistakes",
     "items": [
      {
       "dont": "npm install sharp on Node.js 18",
       "fix": "Upgrade to Node.js 20.9+ (or pin sharp 0.34 on Node.js 18)",
       "why": "sharp 0.35 dropped Node.js 18."
      },
      {
       "dont": "Running npm install on a Mac and uploading node_modules to a Linux server or AWS Lambda",
       "fix": "Install for the target, e.g. npm install --cpu=x64 --os=linux --libc=glibc sharp, or install on the server itself",
       "why": "Package managers pick the ready-built files for the machine that runs the install."
      },
      {
       "dont": "Letting webpack or esbuild bundle sharp into server code",
       "fix": "Mark sharp as external (webpack externals, esbuild --external:sharp)",
       "why": "sharp loads native files at run time and must stay in node_modules."
      },
      {
       "dont": "sharp(input).resize(800).toFile('out.jpg') on phone photos",
       "fix": "sharp(input).autoOrient().resize(800).toFile('out.jpg')",
       "why": "Output strips EXIF orientation, so photos taken sideways stay sideways."
      },
      {
       "dont": "sharp(input, { failOnError: false })",
       "fix": "sharp(input, { failOn: 'none' }), only for trusted input",
       "why": "The failOnError option was removed in 0.35; failOn controls how strict decoding is."
      }
     ]
    }
   ]
  },
  {
   "id": "faq",
   "nav": "Questions",
   "h2": "Questions",
   "parts": [
    {
     "t": "faq",
     "items": [
      {
       "q": "Can I use sharp in the browser or in a React component?",
       "a": "No. Run it on your server, in a serverless function or in your build; the docs say browser use is unsupported.",
       "evidence": {
        "url": "https://sharp.pixelplumbing.com/install/",
        "quote": "Use in web browsers is unsupported."
       }
      },
      {
       "q": "Which image formats can it read and write?",
       "a": "It reads JPEG, PNG, WebP, GIF, AVIF, TIFF and SVG, and writes JPEG, PNG, WebP, GIF, AVIF and TIFF.",
       "evidence": {
        "url": "https://sharp.pixelplumbing.com/",
        "quote": "This module supports reading JPEG, PNG, WebP, GIF, AVIF, TIFF and SVG images."
       }
      },
      {
       "q": "Why do my phone photos come out sideways?",
       "a": "Output drops the camera orientation data. Call autoOrient() before resizing.",
       "evidence": {
        "url": "https://sharp.pixelplumbing.com/api-output/",
        "quote": "By default all metadata will be removed, which includes EXIF-based orientation."
       }
      },
      {
       "q": "Does it work on AWS Lambda?",
       "a": "Yes, if your deployment package holds the Linux build for the function's chip type.",
       "evidence": {
        "url": "https://sharp.pixelplumbing.com/install/",
        "quote": "The node_modules directory of the deployment package must include binaries for either the linux-x64 or linux-arm64 platforms depending on the chosen architecture."
       }
      },
      {
       "q": "Is it safe for images uploaded by strangers?",
       "a": "It treats all input as untrusted, rejects files with decode warnings and limits the pixel count by default.",
       "evidence": {
        "url": "https://sharp.pixelplumbing.com/security/",
        "quote": "All input is assumed to be untrusted and will be rejected if there are any warnings whilst decoding is attempted."
       }
      }
     ]
    }
   ]
  }
 ],
 "glance": [
  [
   "Package",
   "npm sharp"
  ],
  [
   "Category",
   "Files, images and media"
  ],
  [
   "License",
   "Apache-2.0"
  ],
  [
   "Latest version",
   "v0.35.5, September 27, 2026"
  ],
  [
   "On GitHub since",
   "August 2013"
  ],
  [
   "Gid Score",
   "84.0"
  ],
  [
   "Rank in category",
   "#1 of 281"
  ],
  [
   "GitHub",
   "lovell/sharp"
  ],
  [
   "Last change",
   "Nov 24, 2026"
  ]
 ],
 "good": [
  "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."
 ],
 "checked_line": "Read by AgentGid from 11 official pages, card checked Nov 11, 2026; numbers update daily.",
 "logo": "https://agentgid.com/media/avatars/lovell.png"
}