Complete Image Quantization Library in TypeScript (MIT License)
- API Documentation and Usage
- Introduction
- Features
- Todo
- Breaking changes
- Changelog
- Credits
- References
- License
Image Color Number Reduction with alpha support using RGBQuant/NeuQuant/Xiaolin Wu's algorithms and Euclidean/Manhattan/CIEDE2000 color distance formulas in TypeScript
-
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 #4 (comment)CIEDE2000
- 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
// will import ESM (ESNext) or UMD version depending on your bundler/node
import * as iq from 'image-q';
var iq = require('image-q');
<script
src="<path-to image-q/dist/umd/image-q.js>"
type="text/javascript"
charset="utf-8"
></script>
Please refer to API Documentation and Usage
+ PaletteQuantizer#quantize => PaletteQuantizer#quantizeSync
+ ImageQuantizer#quantize => ImageQuantizer#quantizeSync
+ 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
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)
+ Test cases for different types of imports and requres added
+ Try to solve exported bundle types problem. 'umd' bundle removed.
+ Test case for issue #95 added
+ Fixes #96: Fix minimumColorDistanceToDither (PR #97 by @pixelplanetdev)
+ Fixes #95: "Always empty result in certain webpack / babel configs" (PR #98)
+ Fixes issue "Module not found: Can't resolve 'core-js/fn/set-immediate' in ..."
+ pnpm monorepo, esbuild for faster builds, typescript upgraded
+ Basic (Simple) API implemented
+ see breaking changes
+ @types/node moved to 'dependencies'
+ documentation added
+ some refactorings/renames, see breaking changes
+ circular dependency removed
+ readme updated
+ 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
+ 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
+ Refactoring
+ Riemersma dithering added (Hilbert Curve)
+ Readme.md updated
+ build.cmd updated
+ 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
+ Documentation generation fixed
+ File name case problem fixed
+ Auto-generated documentation added
+ Refactoring
+ Code cleanup, removed unnecessary files
+ 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
+ CIEDE2000 color distance equation optimized (original CIEDE2000 equation is available as class `CIEDE2000_Original`)
+ CMetric color distance fixed
+ Cleanup
+ Draft of CMetric color distance added
+ rgb2xyz & xyz2lab fixed. CIEDE2000 works much better now.
+ CIE94 distance formula added. More investigation is needed.
+ Initial
Thanks to Leon Sorokin for information share and his original RGBQuant!
-
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
- HUSL (Boronine) - info
- HUSL (Boronine) - code
- Color Image Quantization for Frame Buffer Display
- K-Means
- Efficient Color Quantization by Hierarchical Clustering Algorithms
- http://www.codeproject.com/Articles/66341/A-Simple-Yet-Quite-Powerful-Palette-Quantizer-in-C