
Security News
Open Source Maintainers Demand Ability to Block Copilot-Generated Issues and PRs
Open source maintainers are urging GitHub to let them block Copilot from submitting AI-generated issues and pull requests to their repositories.
colour-extractor-fixed
Advanced tools
(This is a working version of josip's node-colour-extractor)
Extract colour palettes from photos using Node.js.
Download and Install ImageMagick
here
NOTE: Windows users should check installation options as shown here.
For run-time issues, you can refer to this one.
$ npm i -g gm
$ npm i colour-extractor-fixed --save
NOTE: colour-extractor-fixed
depends on gm module, which in turn depends on GraphicsMagick.
colour-extractor-fixed
exports two functions:
ce = require('colour-extractor-fixed')
ce.topColours('Photos/Cats/01.jpg', true, function (colours) {
console.log(colours);
});
topColours
function takes three arguments:
true
if you'd like the resulting array to be sorted by frequency,
false
if you'd like to get colours sorted as they appear in the photo (top-to-bottom),Callback function will be passed an Array
with RGB triplet of each colour and its frequency:
[
[1, [46, 70, 118]],
[0.3, [0, 0, 2]],
[0.2, [12, 44, 11]]
]
The second function, colourKey
, returns an array with nine colours, where each one can be mapped to a 3x3 box, ie. super-pixelised representation of the photo.
ce.colourKey('Photos/Cats/999999.jpg', function (colours) {
database.store('colour-keys', photoId, colours);
res.send(colours);
// render colours to user while they wait for the photo to load.
// (or something equally brilliant)
});
colour-extractor-fixed
exports two more utility functions:
> ce.rgb2hex(100, 10, 12);
'#640a0c'
> ce.rgb2hex([44, 44, 44]);
'#2c2c2c'
> ce.hex2rgb('#ffffff');
[255, 255, 255]
> ce.hex2rgb('45c092')
[69, 192, 146]
That's what I'd like to know as well! Anyhow, colour-extractor-fixed
parses GraphicMagick's histogram, tries to detect similar colours and remove ones which appear less frequently than others.
If you happen to know an actual algorithm that deals with this sort of stuff, don't hesitate to contact me!
colour-extractor-fixed is published under MMIT license, please see the LICENSE file for full details.
Photos used in the sample can be downloaded from Flickr:
FAQs
Extract colour palettes from images
The npm package colour-extractor-fixed receives a total of 0 weekly downloads. As such, colour-extractor-fixed popularity was classified as not popular.
We found that colour-extractor-fixed demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Open source maintainers are urging GitHub to let them block Copilot from submitting AI-generated issues and pull requests to their repositories.
Research
Security News
Malicious Koishi plugin silently exfiltrates messages with hex strings to a hardcoded QQ account, exposing secrets in chatbots across platforms.
Research
Security News
Malicious PyPI checkers validate stolen emails against TikTok and Instagram APIs, enabling targeted account attacks and dark web credential sales.