Installations
npm install heic-convert
Developer Guide
Typescript
No
Module System
CommonJS
Min. Node Version
>=12.0.0
Node Version
16.20.2
NPM Version
8.19.4
Score
98.1
Supply Chain
99.4
Quality
75.8
Maintenance
100
Vulnerability
98.6
License
Releases
Unable to fetch releases
Contributors
Unable to fetch Contributors
Languages
JavaScript (100%)
Developer
catdad-experiments
Download Statistics
Total Downloads
5,030,368
Last Day
16,094
Last Week
67,341
Last Month
266,626
Last Year
2,525,032
GitHub Statistics
263 Stars
68 Commits
28 Forks
7 Watching
1 Branches
2 Contributors
Bundle Size
1.24 MB
Minified
461.01 kB
Minified + Gzipped
Package Meta Information
Latest Version
2.1.0
Package Id
heic-convert@2.1.0
Unpacked Size
7.74 kB
Size
2.78 kB
File Count
7
NPM Version
8.19.4
Node Version
16.20.2
Publised On
30 Nov 2023
Total Downloads
Cumulative downloads
Total Downloads
5,030,368
Last day
4.3%
16,094
Compared to previous day
Last week
-5.1%
67,341
Compared to previous week
Last month
5.8%
266,626
Compared to previous month
Last year
77.1%
2,525,032
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Dependencies
3
heic-convert
Convert HEIC/HEIF images to JPEG and PNG
Install
1npm install heic-convert
Usage in NodeJS
Convert the main image in a HEIC to JPEG
1const { promisify } = require('util'); 2const fs = require('fs'); 3const convert = require('heic-convert'); 4 5(async () => { 6 const inputBuffer = await promisify(fs.readFile)('/path/to/my/image.heic'); 7 const outputBuffer = await convert({ 8 buffer: inputBuffer, // the HEIC file buffer 9 format: 'JPEG', // output format 10 quality: 1 // the jpeg compression quality, between 0 and 1 11 }); 12 13 await promisify(fs.writeFile)('./result.jpg', outputBuffer); 14})();
Convert the main image in a HEIC to PNG
1const { promisify } = require('util'); 2const fs = require('fs'); 3const convert = require('heic-convert'); 4 5(async () => { 6 const inputBuffer = await promisify(fs.readFile)('/path/to/my/image.heic'); 7 const outputBuffer = await convert({ 8 buffer: inputBuffer, // the HEIC file buffer 9 format: 'PNG' // output format 10 }); 11 12 await promisify(fs.writeFile)('./result.png', outputBuffer); 13})();
Convert all images in a HEIC
1const { promisify } = require('util'); 2const fs = require('fs'); 3const convert = require('heic-convert'); 4 5(async () => { 6 const inputBuffer = await promisify(fs.readFile)('/path/to/my/image.heic'); 7 const images = await convert.all({ 8 buffer: inputBuffer, // the HEIC file buffer 9 format: 'JPEG' // output format 10 }); 11 12 for (let idx in images) { 13 const image = images[idx]; 14 const outputBuffer = await image.convert(); 15 await promisify(fs.writeFile)(`./result-${idx}.jpg`, outputBuffer); 16 } 17})();
The work to convert an image is done when calling image.convert()
, so if you only need one of the images in a multi-image file, you can convert just that one from the images
array and skip doing any work for the remaining images.
Note that while the converter returns a Promise and is overall asynchronous, a lot of work is still done synchronously, so you should consider using a worker thread in order to not block the main thread in highly concurrent production environments.
Usage in the browser
While the NodeJS version of heic-convert
may be compiled for use in the browser with something like webpack
, not all build tools necessarily like to compile all modules well. However, what further complicates things is that this module uses pure-javascript implementations of a jpeg and png encoder. But the browser has its own native encoders! Let's just use those instead of including a ton of extra code in your bundle.
When compiling a client-side project, use:
1const convert = require('heic-convert/browser');
This is currently only supported in the main thread. Support for workers may be added in the future, but if you need it sooner, please create an issue or even a PR!
Related
- heic-cli - convert heic/heif images to jpeg or png from the command line
- heic-decode - decode heic images to raw image data
- libheif-js - libheif as a pure-javascript npm module
![Empty State](/_next/static/media/empty.e5fae2e5.png)
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
1 commit(s) and 1 issue activity found in the last 90 days -- score normalized to 1
Reason
Found 0/12 approved changesets -- score normalized to 0
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:19: update your workflow using https://app.stepsecurity.io/secureworkflow/catdad-experiments/heic-convert/ci.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:20: update your workflow using https://app.stepsecurity.io/secureworkflow/catdad-experiments/heic-convert/ci.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:33: update your workflow using https://app.stepsecurity.io/secureworkflow/catdad-experiments/heic-convert/ci.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:34: update your workflow using https://app.stepsecurity.io/secureworkflow/catdad-experiments/heic-convert/ci.yml/master?enable=pin
- Warn: npmCommand not pinned by hash: .github/workflows/ci.yml:24
- Info: 0 out of 4 GitHub-owned GitHubAction dependencies pinned
- Info: 0 out of 1 npmCommand dependencies pinned
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
detected GitHub workflow tokens with excessive permissions
Details
- Warn: no topLevel permission defined: .github/workflows/ci.yml:1
- Info: no jobLevel write permissions found
Reason
license file not detected
Details
- Warn: project does not have a license file
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
branch protection not enabled on development/release branches
Details
- Warn: branch protection not enabled for branch 'master'
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
- Warn: 0 commits out of 22 are checked with a SAST tool
Score
3.2
/10
Last Scanned on 2025-02-03
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 More