High performance Node.js image processing, the fastest module to resize JPEG, PNG, WebP, AVIF and TIFF images. Uses the libvips library.
Installations
npm install sharp
Developer Guide
Typescript
Yes
Module System
CommonJS
Min. Node Version
^18.17.0 || ^20.3.0 || >=21.0.0
Node Version
18.18.0
NPM Version
9.8.1
Score
60.6
Supply Chain
94.7
Quality
81.6
Maintenance
100
Vulnerability
92.8
License
Releases
Contributors
Languages
JavaScript (76.41%)
C++ (20.1%)
TypeScript (2.03%)
Python (1.14%)
Dockerfile (0.13%)
Shell (0.12%)
C (0.07%)
Developer
Download Statistics
Total Downloads
692,841,079
Last Day
455,000
Last Week
5,462,600
Last Month
30,454,840
Last Year
292,955,404
GitHub Statistics
29,507 Stars
2,156 Commits
1,302 Forks
229 Watching
3 Branches
210 Contributors
Sponsor this package
Package Meta Information
Latest Version
0.33.5
Package Id
sharp@0.33.5
Unpacked Size
491.04 kB
Size
110.76 kB
File Count
32
NPM Version
9.8.1
Node Version
18.18.0
Publised On
16 Aug 2024
Total Downloads
Cumulative downloads
Total Downloads
692,841,079
Last day
-67.6%
455,000
Compared to previous day
Last week
-27.3%
5,462,600
Compared to previous week
Last month
0.5%
30,454,840
Compared to previous month
Last year
87.5%
292,955,404
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Dependencies
3
Dev Dependencies
21
Optional Dependencies
19
sharp
The typical use case for this high speed Node-API module is to convert large images in common formats to smaller, web-friendly JPEG, PNG, WebP, GIF and AVIF images of varying dimensions.
It can be used with all JavaScript runtimes that provide support for Node-API v9, including Node.js (^18.17.0 or >= 20.3.0), Deno and Bun.
Resizing an image is typically 4x-5x faster than using the quickest ImageMagick and GraphicsMagick settings due to its use of libvips.
Colour spaces, embedded ICC profiles and alpha transparency channels are all handled correctly. Lanczos resampling ensures quality is not sacrificed for speed.
As well as image resizing, operations such as rotation, extraction, compositing and gamma correction are available.
Most modern macOS, Windows and Linux systems do not require any additional install or runtime dependencies.
Documentation
Visit sharp.pixelplumbing.com for complete installation instructions, API documentation, benchmark tests and changelog.
Examples
1npm install sharp
1const sharp = require('sharp');
Callback
1sharp(inputBuffer) 2 .resize(320, 240) 3 .toFile('output.webp', (err, info) => { ... });
Promise
1sharp('input.jpg') 2 .rotate() 3 .resize(200) 4 .jpeg({ mozjpeg: true }) 5 .toBuffer() 6 .then( data => { ... }) 7 .catch( err => { ... });
Async/await
1const semiTransparentRedPng = await sharp({ 2 create: { 3 width: 48, 4 height: 48, 5 channels: 4, 6 background: { r: 255, g: 0, b: 0, alpha: 0.5 } 7 } 8}) 9 .png() 10 .toBuffer();
Stream
1const roundedCorners = Buffer.from( 2 '<svg><rect x="0" y="0" width="200" height="200" rx="50" ry="50"/></svg>' 3); 4 5const roundedCornerResizer = 6 sharp() 7 .resize(200, 200) 8 .composite([{ 9 input: roundedCorners, 10 blend: 'dest-in' 11 }]) 12 .png(); 13 14readableStream 15 .pipe(roundedCornerResizer) 16 .pipe(writableStream);
Contributing
A guide for contributors covers reporting bugs, requesting features and submitting code changes.
Licensing
Copyright 2013 Lovell Fuller and others.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Stable Version
Stable Version
0.33.5
HIGH
1
7.8/10
Summary
sharp vulnerability in libwebp dependency CVE-2023-4863
Affected Versions
< 0.32.6
Patched Versions
0.32.6
MODERATE
1
6.5/10
Summary
sharp vulnerable to Command Injection in post-installation over build environment
Affected Versions
< 0.30.5
Patched Versions
0.30.5
Reason
2 commit(s) and 24 issue activity found in the last 90 days -- score normalized to 10
Reason
security policy file detected
Details
- Info: security policy file detected: .github/SECURITY.md:1
- Info: Found linked content: .github/SECURITY.md:1
- Info: Found disclosure, vulnerability, and/or timelines in security policy: .github/SECURITY.md:1
- Info: Found text in security policy: .github/SECURITY.md:1
Reason
no dangerous workflow patterns detected
Reason
GitHub workflow tokens follow principle of least privilege
Details
- Warn: jobLevel 'contents' permission set to 'write': .github/workflows/ci.yml:9
- Warn: jobLevel 'contents' permission set to 'write': .github/workflows/ci.yml:126
- Warn: jobLevel 'contents' permission set to 'write': .github/workflows/ci.yml:178
- Info: found token with 'none' permissions: .github/workflows/ci.yml:1
- Info: found token with 'none' permissions: .github/workflows/npm.yml:1
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
- Info: project has a license file: LICENSE:0
- Info: FSF or OSI recognized license: Apache License 2.0: LICENSE:0
Reason
project is fuzzed
Details
- Info: OSSFuzz integration found
Reason
Found 6/30 approved changesets -- score normalized to 2
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
Project has not signed or included provenance with any releases.
Details
- Warn: release artifact v0.33.5 not signed: https://api.github.com/repos/lovell/sharp/releases/170530436
- Warn: release artifact v0.33.5-rc.1 not signed: https://api.github.com/repos/lovell/sharp/releases/170113814
- Warn: release artifact v0.33.5-rc.0 not signed: https://api.github.com/repos/lovell/sharp/releases/169989487
- Warn: release artifact v0.33.4 not signed: https://api.github.com/repos/lovell/sharp/releases/156060196
- Warn: release artifact v0.33.4-rc.0 not signed: https://api.github.com/repos/lovell/sharp/releases/156054783
- Warn: release artifact v0.33.5 does not have provenance: https://api.github.com/repos/lovell/sharp/releases/170530436
- Warn: release artifact v0.33.5-rc.1 does not have provenance: https://api.github.com/repos/lovell/sharp/releases/170113814
- Warn: release artifact v0.33.5-rc.0 does not have provenance: https://api.github.com/repos/lovell/sharp/releases/169989487
- Warn: release artifact v0.33.4 does not have provenance: https://api.github.com/repos/lovell/sharp/releases/156060196
- Warn: release artifact v0.33.4-rc.0 does not have provenance: https://api.github.com/repos/lovell/sharp/releases/156054783
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
- Warn: 0 commits out of 6 are checked with a SAST tool
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:94: update your workflow using https://app.stepsecurity.io/secureworkflow/lovell/sharp/ci.yml/main?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:99: update your workflow using https://app.stepsecurity.io/secureworkflow/lovell/sharp/ci.yml/main?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:104: update your workflow using https://app.stepsecurity.io/secureworkflow/lovell/sharp/ci.yml/main?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:155: update your workflow using https://app.stepsecurity.io/secureworkflow/lovell/sharp/ci.yml/main?enable=pin
- Warn: third-party GitHubAction not pinned by hash: .github/workflows/ci.yml:156: update your workflow using https://app.stepsecurity.io/secureworkflow/lovell/sharp/ci.yml/main?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:184: update your workflow using https://app.stepsecurity.io/secureworkflow/lovell/sharp/ci.yml/main?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:188: update your workflow using https://app.stepsecurity.io/secureworkflow/lovell/sharp/ci.yml/main?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/npm.yml:99: update your workflow using https://app.stepsecurity.io/secureworkflow/lovell/sharp/npm.yml/main?enable=pin
- Warn: third-party GitHubAction not pinned by hash: .github/workflows/npm.yml:104: update your workflow using https://app.stepsecurity.io/secureworkflow/lovell/sharp/npm.yml/main?enable=pin
- Warn: third-party GitHubAction not pinned by hash: .github/workflows/npm.yml:109: update your workflow using https://app.stepsecurity.io/secureworkflow/lovell/sharp/npm.yml/main?enable=pin
- Warn: third-party GitHubAction not pinned by hash: .github/workflows/npm.yml:114: update your workflow using https://app.stepsecurity.io/secureworkflow/lovell/sharp/npm.yml/main?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/npm.yml:120: update your workflow using https://app.stepsecurity.io/secureworkflow/lovell/sharp/npm.yml/main?enable=pin
- Warn: third-party GitHubAction not pinned by hash: .github/workflows/npm.yml:125: update your workflow using https://app.stepsecurity.io/secureworkflow/lovell/sharp/npm.yml/main?enable=pin
- Warn: third-party GitHubAction not pinned by hash: .github/workflows/npm.yml:136: update your workflow using https://app.stepsecurity.io/secureworkflow/lovell/sharp/npm.yml/main?enable=pin
- Warn: containerImage not pinned by hash: test/bench/Dockerfile:1: pin your Docker image by updating ubuntu:23.10 to ubuntu:23.10@sha256:fd7fe639db24c4e005643921beea92bc449aac4f4d40d60cd9ad9ab6456aec01
- Warn: npmCommand not pinned by hash: test/bench/Dockerfile:19
- Warn: npmCommand not pinned by hash: test/bench/Dockerfile:22
- Warn: npmCommand not pinned by hash: .github/workflows/ci.yml:107
- Warn: npmCommand not pinned by hash: .github/workflows/ci.yml:114
- Warn: npmCommand not pinned by hash: .github/workflows/ci.yml:208
- Warn: npmCommand not pinned by hash: .github/workflows/npm.yml:147
- Info: 0 out of 8 GitHub-owned GitHubAction dependencies pinned
- Info: 0 out of 6 third-party GitHubAction dependencies pinned
- Info: 0 out of 6 npmCommand dependencies pinned
- Info: 0 out of 1 containerImage dependencies pinned
Score
6.8
/10
Last Scanned on 2024-12-23
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn MoreOther packages similar to sharp
@types/sharp
Stub TypeScript definitions entry for sharp, which provides its own types definitions
@img/sharp-libvips-linux-x64
Prebuilt libvips and dependencies for use with sharp on Linux (glibc) x64
@img/sharp-libvips-linuxmusl-x64
Prebuilt libvips and dependencies for use with sharp on Linux (musl) x64
gatsby-sharp