Open elrumordelaluz opened 5 years ago
Any update on when this pull request can be merged and released? This update would be immensely helpful.
same issue (I think), I get Invalid file type
(https://github.com/scijs/get-pixels/blob/b389ffc3408b1be50f63fe8bd0837f17a48f1f27/node-pixels.js#L137)
I made it working for me with the follow patch (dist only) and pass it as [buffer, type]
to getColor
diff --git a/node_modules/colorthief/dist/color-thief.js b/node_modules/colorthief/dist/color-thief.js
index 2833cec..1fe5714 100644
--- a/node_modules/colorthief/dist/color-thief.js
+++ b/node_modules/colorthief/dist/color-thief.js
@@ -48,13 +48,20 @@ function validateOptions(options) {
function loadImg(img) {
return new Promise((resolve, reject) => {
- getPixels(img, function(err, data) {
- if(err) {
+ let params;
+ if (Array.isArray(img)) {
+ params = img;
+ } else {
+ params = [img];
+ }
+ params.push(function (err, data) {
+ if (err) {
reject(err)
} else {
resolve(data);
}
- })
+ });
+ getPixels(...img)
});
}
A vote from me. I'm having to fork the library because this is missing from the current code base.
You could use https://www.npmjs.com/package/patch-package if you don't want to fork, like I did for my patch above
Bump
any news when this is going to get merged ?
Bump
Bump. I already have the image in a Buffer after doing processing through sharp. I'd rather not write it to a temp file just so it can be read back.
Bump
Bump
Bump
any update?
Please merge, we need this!
Can someone merge this damn PR
First, thanks for this great Library!
Working with this cool Library (congrats and thanks!) in
node.js
, in particular making responsimage I found that theimage
(input) value could be not only a path string to the image but also aBuffer
, since theurl
argument:And this is cool, and sound coherent when working in
node
. But in this scenario I found that the second argumenttype
is needed:So made this PR to fix that part, adding the relative test. ~Keep in mind that I didn't include the
/dist
with bundled files.~ I added this folder to let use my repo as thepackages
source in the meanwhile (otherwise, some projects are broken)Let me know in any case and thanks again for this great Library!