Image Quantization Library with alpha support (based on https://github.com/leeoniya/RgbQuant.js, https://github.com/timoxley/neuquant and http://www.ece.mcmaster.ca/~xwu/cq.c)
Installations
npm install image-q
Developer Guide
Typescript
Yes
Module System
CommonJS, ESM
Node Version
14.18.2
NPM Version
6.14.15
Releases
Contributors
Unable to fetch Contributors
Languages
TypeScript (98.62%)
JavaScript (1.38%)
Developer
ibezkrovnyi
Download Statistics
Total Downloads
190,938,658
Last Day
185,587
Last Week
878,511
Last Month
3,943,706
Last Year
48,605,999
GitHub Statistics
146 Stars
167 Commits
11 Forks
5 Watching
885 Branches
2 Contributors
Bundle Size
45.51 kB
Minified
12.41 kB
Minified + Gzipped
Package Meta Information
Latest Version
4.0.0
Package Id
image-q@4.0.0
Unpacked Size
825.63 kB
Size
164.04 kB
File Count
140
NPM Version
6.14.15
Node Version
14.18.2
Total Downloads
Cumulative downloads
Total Downloads
190,938,658
Last day
4.7%
185,587
Compared to previous day
Last week
-12.2%
878,511
Compared to previous week
Last month
1.2%
3,943,706
Compared to previous month
Last year
1.7%
48,605,999
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Dependencies
1
Dev Dependencies
4
image-q
Complete Image Quantization Library in TypeScript (MIT License)
Table of Contents
- API Documentation and Usage
- Introduction
- Features
- Todo
- Breaking changes
- Changelog
- Credits
- References
- License
Introduction
Image Color Number Reduction with alpha support using RGBQuant/NeuQuant/Xiaolin Wu's algorithms and Euclidean/Manhattan/CIEDE2000 color distance formulas in TypeScript
Features
-
Platforms supported
- Browser (Chrome 7.0+, FireFox 4.0+, IE 10+, Opera 11.6+, Safari 5.1+)
- Node.js 6.0+
-
API
- Basic API: sync and promise-based async
- Advanced API: sync and generator-based
-
Builds
dist/cjs/image-q.js
- CommonJSdist/esm/image-q.js
- ESM (ESNext)dist/cjs/image-q.js
- UMD
-
Import
HTMLImageElement
HTMLCanvasElement
NodeCanvas
ImageData
Array
CanvasPixelArray
Uint8Array
Uint32Array
-
Color Distance
Euclidean
- 1/1/1/1 coefficients (originally used in Xiaolin Wu's Quantizer WuQuant)EuclideanBT709NoAlpha
- BT.709 sRGB coefficients (originally used in RGBQuant)EuclideanBT709
BT.709 sRGB coefficients + alpha supportManhattan
- 1/1/1/1 coefficients (originally used in NeuQuant)ManhattanBT709
- BT.709 sRGB coefficientsManhattanNommyde
- see https://github.com/igor-bezkrovny/image-quantization/issues/4#issuecomment-234527620CIEDE2000
- CIEDE2000 (very slow)CIE94Textiles
- CIE94 implementation for textilesCIE94GraphicArts
- CIE94 implementation for graphic artsCMetric
- see http://www.compuphase.com/cmetric.htmPNGQuant
- used in pngQuant tool
-
Palette Quantizers
NeuQuant
(original code ported, integer calculations)NeuQuantFloat
(floating-point calculations)RGBQuant
WuQuant
-
Image Quantizers
NearestColor
ErrorDiffusionArray
- two modes of error propagation are supported:xnview
andgimp
FloydSteinberg
FalseFloydSteinberg
Stucki
Atkinson
Jarvis
Burkes
Sierra
TwoSierra
SierraLite
ErrorDiffusionRiemersma
- Hilbert space-filling curve is used
-
Output
Uint32Array
Uint8Array
Include image-q
library into your project
ES6 module
1// will import ESM (ESNext) or UMD version depending on your bundler/node 2import * as iq from 'image-q';
CommonJS
1var iq = require('image-q');
As a global variable (Browser)
1<script 2 src="<path-to image-q/dist/umd/image-q.js>" 3 type="text/javascript" 4 charset="utf-8" 5></script>
How to use
Please refer to API Documentation and Usage
Breaking changes
2.1.1
+ PaletteQuantizer#quantize => PaletteQuantizer#quantizeSync
+ ImageQuantizer#quantize => ImageQuantizer#quantizeSync
2.0.1 - 2.0.4 (2018-02-22)
+ EuclideanRgbQuantWOAlpha => EuclideanBT709NoAlpha
+ EuclideanRgbQuantWithAlpha => EuclideanBT709
+ ManhattanSRGB => ManhattanBT709
+ IImageDitherer => AbstractImageQuantizer
+ IPaletteQuantizer => AbstractPaletteQuantizer
+ PointContainer.fromNodeCanvas => PointContainer.fromHTMLCanvasElement
+ PointContainer.fromArray => PointContainer.fromUint8Array
+ PointContainer.fromBuffer (Node.js, new)
+ CMETRIC => CMetric
+ PNGQUANT => PNGQuant
+ SSIM Class => ssim function
TODO
notification about progressriemersma dithering- ordered dithering <-- is there anyone who needs it?
- readme update, more examples
- demo update (latest image-q npm version should be used in demo)
Changelog
4.0.0
+ Test cases for different types of imports and requres added
4.0.0-alpha
+ Try to solve exported bundle types problem. 'umd' bundle removed.
3.0.8
+ Test case for issue #95 added
3.0.7
+ Fixes #96: Fix minimumColorDistanceToDither (PR #97 by @pixelplanetdev)
3.0.6
+ Fixes #95: "Always empty result in certain webpack / babel configs" (PR #98)
3.0.4
+ Fixes issue "Module not found: Can't resolve 'core-js/fn/set-immediate' in ..."
3.0.0
+ pnpm monorepo, esbuild for faster builds, typescript upgraded
2.1.1
+ Basic (Simple) API implemented
+ see breaking changes
2.0.5 (2018-02-23)
+ @types/node moved to 'dependencies'
2.0.4 (2018-02-23)
+ documentation added
+ some refactorings/renames, see breaking changes
2.0.3 (2018-02-22)
+ circular dependency removed
2.0.2 (2018-02-22)
+ readme updated
2.0.1 (2018-02-22)
+ progress tracking api (using es6 generators) added
+ strinct lint rules (+code cleanup/renames)
+ rollup (3 different versions - umd, cjs, esm + source maps + d.ts)
+ latest TypeScript
+ jest
+ snapshot tests
+ coverage (+coveralls)
+ greenkeeper
1.1.1 (2016-08-28)
+ CIEDE2000 - incorrect calculation fixed
+ CIEDE2000 - alpha channel now has only 25% impact on color distance instead of 66%
+ CIE94 - added 2 types (textiles and graphics art) according to spec
+ CIE94 - alpha support added
+ rgb2xyz, lab2xyz, xyz2rgb, xyz2lab - gamma correction
+ lab2xyz, xyz2lab - refY should be 100 (1.00000) instead of 10 (0.10000)
+ manhattan with new (Nommyde) coefficients added
+ mocha tests added
+ webpack integration
+ image-q is now UMD module
+ travis-ci integration
+ typescript 2.0
+ indentation with 4 spaces
0.1.4 (2015-06-24)
+ Refactoring
+ Riemersma dithering added (Hilbert Curve)
+ Readme.md updated
+ build.cmd updated
0.1.3 (2015-06-16)
+ NeuQuant is fixed (again) according to original Anthony Dekker source code (all values should be integer)
+ Error Diffusion Dithering is now calculates error like XNVIEW
+ Refactoring
0.1.2 (2015-06-16)
+ Documentation generation fixed
+ File name case problem fixed
0.1.1 (2015-06-16)
+ Auto-generated documentation added
+ Refactoring
0.1.0 (2015-06-16)
+ Code cleanup, removed unnecessary files
0.0.5 (2015-06-16)
+ PNGQuant color distance added, need to check its quality
+ CIEDE2000 and CIE94 fixed for use in NeuQuant
+ NeuQuant is fixed according to original Anthony Dekker source code (all values should be integer)
+ Code refactoring and cleanup
* We have some slowdown because of red/green/blue/alpha normalization according to white point per each calculateRaw/calculateNormalized call
0.0.4 (2015-06-15)
+ CIEDE2000 color distance equation optimized (original CIEDE2000 equation is available as class `CIEDE2000_Original`)
0.0.3b (2015-06-11)
+ CMetric color distance fixed
0.0.3a (2015-06-11)
+ Cleanup
+ Draft of CMetric color distance added
0.0.2 (2015-06-10)
+ rgb2xyz & xyz2lab fixed. CIEDE2000 works much better now.
+ CIE94 distance formula added. More investigation is needed.
0.0.1
+ Initial
Credits
Thanks to Leon Sorokin for information share and his original RGBQuant!
References
-
Palette Quantization Algorithms
- RGBQuant (Leon Sorokin)
JavaScript
- NeuQuant (Johan Nordberg)
TypeScript
- NeuQuant (Tim Oxley)
JavaScript
- NeuQuant (Devon Govett)
JavaScript
- NeuQuant32 (Stuart Coyle)
C
- Xiaolin Wu (Xiaolin Wu)
C
- Xiaolin Wu (Smart-K8)
C#
- Xiaolin Wu w/ Alpha (Matt Wrock) How to add Alpha, Source Code
C#
- MedianCut (mwcz)
GPLv3
- RGBQuant (Leon Sorokin)
-
Image Quantization Algorithms
-
Color Distance Formulas
- Euclidean Distance
- Manhattan Distance
- CIE94 Distance
- CIEDE2000
- Euclidean Distance w/o Alpha (RGBQuant)
- Euclidean Distance w/o sRGB coefficients (Xiaolin Wu Quant)
- Manhattan Distance w/o sRGB coefficients (NeuQuant)
- CMetric
DRAFT!
-
Color conversion formulas
Be sure to fix rgb2xyz/xyz2lab. Issue is with strange part of code:
r = r > 0.04045 ? ...
. Check http://en.wikipedia.org/wiki/Lab_color_space
-
Image Quality Assessment
- SSIM info
- SSIM (Rhys-e)
Java
License: MIT
- PSNR ? TBD
- MSE ? TBD
-
Other
License
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
SAST tool detected but not run on all commits
Details
- Info: SAST configuration detected: CodeQL
- Warn: 0 commits out of 9 are checked with a SAST tool
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
detected GitHub workflow tokens with excessive permissions
Details
- Info: jobLevel 'contents' permission set to 'read': .github/workflows/codeql-analysis.yml:29
- Info: jobLevel 'actions' permission set to 'read': .github/workflows/codeql-analysis.yml:28
- Warn: no topLevel permission defined: .github/workflows/codeql-analysis.yml:1
- Warn: no topLevel permission defined: .github/workflows/commit.yml:1
- Warn: no topLevel permission defined: .github/workflows/release.yml:1
- Info: no jobLevel write permissions found
Reason
Found 0/30 approved changesets -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
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
license file not detected
Details
- Warn: project does not have a license file
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/codeql-analysis.yml:42: update your workflow using https://app.stepsecurity.io/secureworkflow/ibezkrovnyi/image-quantization/codeql-analysis.yml/main?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/codeql-analysis.yml:46: update your workflow using https://app.stepsecurity.io/secureworkflow/ibezkrovnyi/image-quantization/codeql-analysis.yml/main?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/codeql-analysis.yml:57: update your workflow using https://app.stepsecurity.io/secureworkflow/ibezkrovnyi/image-quantization/codeql-analysis.yml/main?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/codeql-analysis.yml:71: update your workflow using https://app.stepsecurity.io/secureworkflow/ibezkrovnyi/image-quantization/codeql-analysis.yml/main?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/commit.yml:14: update your workflow using https://app.stepsecurity.io/secureworkflow/ibezkrovnyi/image-quantization/commit.yml/main?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/commit.yml:19: update your workflow using https://app.stepsecurity.io/secureworkflow/ibezkrovnyi/image-quantization/commit.yml/main?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/commit.yml:26: update your workflow using https://app.stepsecurity.io/secureworkflow/ibezkrovnyi/image-quantization/commit.yml/main?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/release.yml:14: update your workflow using https://app.stepsecurity.io/secureworkflow/ibezkrovnyi/image-quantization/release.yml/main?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/release.yml:17: update your workflow using https://app.stepsecurity.io/secureworkflow/ibezkrovnyi/image-quantization/release.yml/main?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/release.yml:24: update your workflow using https://app.stepsecurity.io/secureworkflow/ibezkrovnyi/image-quantization/release.yml/main?enable=pin
- Warn: downloadThenRun not pinned by hash: .github/workflows/commit.yml:33
- Warn: downloadThenRun not pinned by hash: .github/workflows/release.yml:31
- Info: 0 out of 10 GitHub-owned GitHubAction dependencies pinned
- Info: 0 out of 2 downloadThenRun dependencies pinned
Reason
37 existing vulnerabilities detected
Details
- Warn: Project is vulnerable to: GHSA-67hx-6x53-jw92
- Warn: Project is vulnerable to: GHSA-93q8-gq69-wqmw
- Warn: Project is vulnerable to: GHSA-fwr7-v2mv-hh25
- Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg
- Warn: Project is vulnerable to: GHSA-x9w5-v3q2-3rhw
- Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275
- Warn: Project is vulnerable to: GHSA-w573-4hg7-7wgq
- Warn: Project is vulnerable to: GHSA-434g-2637-qmqr
- Warn: Project is vulnerable to: GHSA-49q7-c7j4-3p7m
- Warn: Project is vulnerable to: GHSA-977x-g7h5-7qgw
- Warn: Project is vulnerable to: GHSA-f7q4-pwc6-w24p
- Warn: Project is vulnerable to: GHSA-fc9h-whq2-v747
- Warn: Project is vulnerable to: GHSA-74fj-2j2h-c42q
- Warn: Project is vulnerable to: GHSA-pw2r-vq6v-hr8c
- Warn: Project is vulnerable to: GHSA-jchw-25xp-jwwc
- Warn: Project is vulnerable to: GHSA-cxjh-pqwp-8mfp
- Warn: Project is vulnerable to: GHSA-8mmm-9v2q-x3f9
- Warn: Project is vulnerable to: GHSA-9c47-m6qq-7p4h
- Warn: Project is vulnerable to: GHSA-76p3-8jx3-jpfq
- Warn: Project is vulnerable to: GHSA-3rfm-jhwj-7488
- Warn: Project is vulnerable to: GHSA-hhq3-ff78-jv3g
- Warn: Project is vulnerable to: GHSA-5v2h-r2cx-5xgj
- Warn: Project is vulnerable to: GHSA-rrrm-qjm4-v8hf
- Warn: Project is vulnerable to: GHSA-952p-6rrq-rcjv
- Warn: Project is vulnerable to: GHSA-f8q6-p94x-37v3
- Warn: Project is vulnerable to: GHSA-xvch-5gv4-984h
- Warn: Project is vulnerable to: GHSA-hrpp-h998-j3pp
- Warn: Project is vulnerable to: GHSA-p8p7-x288-28g6
- Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw
- Warn: Project is vulnerable to: GHSA-4rq4-32rv-6wp6
- Warn: Project is vulnerable to: GHSA-64g7-mvw6-v9qj
- Warn: Project is vulnerable to: GHSA-4wf5-vphf-c2xc
- Warn: Project is vulnerable to: GHSA-72xf-g2v4-qvf3
- Warn: Project is vulnerable to: GHSA-hc6q-2mpp-qw7j
- Warn: Project is vulnerable to: GHSA-4vvj-4cpr-p986
- Warn: Project is vulnerable to: GHSA-j8xg-fqg3-53r7
- Warn: Project is vulnerable to: GHSA-3h5v-q93c-6h6q
Score
2.9
/10
Last Scanned on 2025-01-27
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 image-q
q-view
[Preview](https://q-hub-q-view.vercel.app/)
@qneyraud/q-image
Vue component for images using picture tag, srcset and lazyload
qimage
Simple Promise Image Loader based on Q
@didit-sdk/ui
<a href="https://docs.didit.me/docs/sdk"> <img alt="didit-sdk" src="https://docs.didit.me/_next/image?url=%2F_next%2Fstatic%2Fmedia%2Fsdk_works.5dcf3190.png&w=3840&q=75" /> </a>