Vibrant-Colors/node-vibrant

Jimp.read is not a function

Susan123456789 opened this issue · 3 comments

I am trying to use node-vibrant on an image Buffer (obtained from an image on s3) in a node.js serverless function.

        const image=
            await s3.getObject({
                Bucket:     bucket,
                Key:        key,
            }).promise();

        const palette = await Vibrant.from(image.Body).getPalette();

However, I keep getting the error:

TypeError: Jimp.read is not a function
    at NodeImage.../../@vibrant/image-node/lib/index.js.NodeImage._loadByJimp (/mnt/c/dev/photobook/image-optimizer/.webpack/image-optimizer/webpack:/mnt/c/dev/photobook/image-optimizer/node_modules/@vibrant/image-node/lib/index.js:61:1)
    at NodeImage.../../@vibrant/image-node/lib/index.js.NodeImage.load (/mnt/c/dev/photobook/image-optimizer/.webpack/image-optimizer/webpack:/mnt/c/dev/photobook/image-optimizer/node_modules/@vibrant/image-node/lib/index.js:72:1)
    at Vibrant.../../@vibrant/core/lib/index.js.Vibrant.getPalette (/mnt/c/dev/photobook/image-optimizer/.webpack/image-optimizer/webpack:/mnt/c/dev/photobook/image-optimizer/node_modules/@vibrant/core/lib/index.js:44:1)
    at Builder.../../@vibrant/core/lib/builder.js.Builder.getPalette (/mnt/c/dev/photobook/image-optimizer/.webpack/image-optimizer/webpack:/mnt/c/dev/photobook/image-optimizer/node_modules/@vibrant/core/lib/builder.js:62:1)

This seems related to #102. I will be addressing it while addressing #96 which currently relies on:

jimp-dev/jimp#815

Being merged

This should be solved in the 3.1.5 release

I faced this problem with 0.16.1 and I was able to resolve it by calling

Jimp.default.read()