colorjs / get-image-colors Goto Github PK
View Code? Open in Web Editor NEWExtract colors from GIF, PNG, JPG, and SVG images
Extract colors from GIF, PNG, JPG, and SVG images
This library looks awesome but for the life of me cant get it going on storybook with webpack or nextjs.
Hello! 👋🏼
This is related with colorjs/get-svg-colors#72. The is-svg
dependency used by get-svg-colors
has a vulnerability, I already opened a PR to fix it colorjs/get-svg-colors#73, as soon as we merge and release this we should update the dependency 😊
Would be very helpful thank you!
Hi Creators,
This app is extremely helpful and works really well. But I am having trouble finding documentation on how I can specify the number of colors I want in my palette.
Can you point me in the direction in the documentation if there is one? If there isn't can y'all write up one?
Thanks.
See: GHSA-w7q9-p3jq-fmhm
get-image-colors depends on get-pixels
with range ^3.3.2
, which depends on jpeg-js
with range ^0.3.2
, which has the vulnerability in the advisory above.
Please remove this deep dependency on the vulnerable jpeg-js
package, which was patched in v0.4.0
I was trying to fetch colours of images that are more than 4 mb (aprox). The library gets stuck and does not respond. We finally have to restart the server once this happens.
More Context:
Because this works fine on my local, does it have to do something with the heap size on the server? Is there a possible way to configure my node server to allow more memory (If that is the issue) ?
So I am trying to loop through an array of image urls to get the average picture's color. When I go to try using a buffer as a picture source, I get an invalid GIF error of some sort. I then try downloading via an axios stream and am able to view the picture after downloading, but get this Marker was not found error...
Error: marker was not found
at decodeScan (/Users/atechooff/Build/Ideea/Webscraper/node_modules/jpeg-js/lib/decoder.js:324:15)
at constructor.parse (/Users/atechooff/Build/Ideea/Webscraper/node_modules/jpeg-js/lib/decoder.js:744:29)
at Object.decode (/Users/atechooff/Build/Ideea/Webscraper/node_modules/jpeg-js/lib/decoder.js:983:11)
at handleJPEG (/Users/atechooff/Build/Ideea/Webscraper/node_modules/get-pixels/node-pixels.js:32:21)
at doParse (/Users/atechooff/Build/Ideea/Webscraper/node_modules/get-pixels/node-pixels.js:114:7)
at /Users/atechooff/Build/Ideea/Webscraper/node_modules/get-pixels/node-pixels.js:190:7
at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:511:3)
Here is my code.
let index2 = 0
let interval2 = setInterval(() => {
downloadImage(images.data[index2].sizes[0].url).then((name) => {
console.log('Writting :', objectName, ' to file')
getColors(__dirname + '/images/' + name + '.jpg').then(colors => {
console.log(colors)
if (colors[0]._rgb[2] >= 180) {
console.log('found good image!')
imageLinks.push(images.data[image].sizes[0].url)
}
})
.catch(err => {
console.log("Error! ", err) //This is where I catch the Marker not found error
})
})
if (++index2 == images.data.length) {
console.log('finished looping through images... on to the next array.')
clearInterval(interval2)
}
}, 1000)
This is my downloadImage function just in case there is something wrong with how im downloading.
const downloadImage = async (url) => {
let name = uuidv4()
const writer = fs.createWriteStream(path.resolve(__dirname + ‘/images/’ + name + ‘.jpg’))
const image = await axios({
url,
method: ‘GET’,
responseType: ‘stream’
})
image.data.pipe(writer)
return new Promise((resolve, reject) => {
writer.on(‘finish’, resolve(name))
writer.on(‘error’, reject)
})
}
example:
count: 7 => return 7colors
count: 8 => return 7 colors
count: 30 => return 29 colors
Hey guys thanks for this great repo.
I created a docker image for this project.
https://hub.docker.com/repository/docker/thebakers/get-image-colors
I makes using the project a lot easier. The only comment you need to know is:
docker run -p 3013:3000 thebakers/get-image-colors:latest
and then use it with: http://localhost:3013/api/color?url=https://res.cloudinary.com/hvioxpubt/image/upload/v1631368381/foplzsz9zemxdfqunr8m.jpg
Hi, I started with this image, it's someone's podcast art: http://static.libsyn.com/p/assets/e/3/f/f/e3ffacb40e9f9ebc/Logo_with_text.jpg
It's a simple graphic that is blue, red, yellow and white. For some reason however, it's giving me back several shades of orange, blue and white (missing yellow and red, don't know where the orange came from):
getColors(filePath).then(colors => {
const palette = colors.map(color => color.hex());
res.send({ palette });
})
"palette": [
"#fbfbfb",
"#252c7c",
"#c37025",
"#c1b8a3",
"#d58180"
]
I need to get dominant color for specific image (or color frequency).
For example, Color Thief can do it.
Is it possible with get-image-colors
?
Thanks
as of right now, this package is adding 5 severe vulnerabilities to my project, itd be nice if the dependencies were updated :)
Hi,
I have an issue when using getColors, it log error: "Error: Invalid File Type"
I am writing the automation scripts in synchronous style with Chimp.
My scripts is as below:
var buffer = fs.readFileSync(path.join(__dirname, '/../../resources/uploadData/', '1.png'));
getColors(buffer, function(error, colors){
if (err) throw err; // it doesn't log error
console.log(buffer); // Log: <Buffer 89 50 4e 47 0d 0a ....>
console.log(error); // Log "Error: Invalid File Type"
});
Please help me where I am wrong? Thanks!
How can i get color data from "req.files.image.tempFilePath" ?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.