Jimp: Error on using image boxShadow

Created on 3 Jan 2019  路  13Comments  路  Source: oliver-moran/jimp

Expected Behavior

Need to create an shading/shadow image.

Current Behavior

Getting error on using image.boxShadow

Failure Information (for bugs)

Debugger listening on ws://127.0.0.1:26445/91cb9e8a-85a4-4dcf-b420-043ca9301d64
Debugger attached.
e:\EDrive\shading\index.js:9
image.boxShadow({ opacity: 0.8, size: 1.2, blur: 10, x: -75, y: -75 });
^

TypeError: image.boxShadow is not a function
at Jimp. (e:\EDrive\shading\index.js:9:15)
at Timeout._onTimeout (e:\EDrive\shading\node_modules\@jimp\core\dist\index.js:331:25)
at ontimeout (timers.js:498:11)
at tryOnTimeout (timers.js:323:5)
at Timer.listOnTimeout (timers.js:290:5)
Waiting for the debugger to disconnect...
TypeError: image.boxShadow is not a function
index.js:9
at Jimp. (e:\EDrive\shading\index.js:9:15)
at Timeout._onTimeout (e:\EDrive\shading\node_modules\@jimp\core\dist\index.js:331:25)
at ontimeout (timers.js:498:11)
at tryOnTimeout (timers.js:323:5)
at Timer.listOnTimeout (timers.js:290:5)

Steps to Reproduce

These are the two file used to create shadow image

Step1: package.json
{
"name": "shading",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"prestart": "npm install",
"start": "node index.js",
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"@jimp/custom": "^0.6.0",
"@jimp/plugin-blur": "^0.6.0",
"@jimp/plugin-resize": "^0.6.0",
"@jimp/plugin-shadow": "^0.6.0",
"@jimp/test-utils": "^0.6.0",
"@jimp/utils": "^0.6.0",
"core-js": "^2.6.1",
"jimp": "^0.6.0"
}
}

step2: index.js

var jimp = require('jimp');
var inputPath = "E:/EDrive/Images/2016_12_07_18_27_16--Project002/img.png";
var outputPath = "E:/EDrive/Images/2016_12_07_18_27_16--Project002/imgshading.png";
jimp.read(inputPath, function (err1, image) {
if (err1){
return reject(err1);
}
image.boxShadow({ opacity: 0.8, size: 1.2, blur: 10, x: -75, y: -75 });

    image.write(outputPath, function (err2, info2) {
        return resolve("1");
    })
});

Context

  • Jimp Version: "jimp": "^0.6.0"
  • Operating System:Windows 10
  • Node version: v8.14.0

Failure Logs

Most helpful comment

After using the reference code of #665.

But for the @jimp/plugin-shadow still it is not working.

Still getting the same error

Here is the sample code

const Jimp = require('jimp')
const shadow = require('@jimp/plugin-shadow')
const configure = require('@jimp/custom')

var inputPath = "E:/EDrive/Images/2016_12_07_18_27_16--Project002/img.png";
var outputPath = "E:/EDrive/Images/2016_12_07_18_27_16--Project002/imgshading1.png";
const MyJimp = configure({ plugins: [shadow] }, Jimp)
// You might be able to just call configure since it modifies the global jimp (I think)
configure({ plugins: [shadow] }, Jimp)
async function main() {
const image = await Jimp.read(inputPath);

try{
    image.boxShadow();
    image.write(outputPath, function (err2, info2) {
        console.log(info2);
     })
}
 catch (err) {
     console.error(err);
 }

}
main();

Output

image

All 13 comments

Have the same error when I try to use "boxShadow".

TypeError: image.boxShadow is not a function

Jimp Version: "jimp": "^0.6.0"
Operating System: mac Mojave 10.14
Node version: v8.12.0

@vinaymuthanna0727 @Ganevru have you tried something like https://github.com/oliver-moran/jimp/issues/665#issuecomment-441412587

After using the reference code of #665.

But for the @jimp/plugin-shadow still it is not working.

Still getting the same error

Here is the sample code

const Jimp = require('jimp')
const shadow = require('@jimp/plugin-shadow')
const configure = require('@jimp/custom')

var inputPath = "E:/EDrive/Images/2016_12_07_18_27_16--Project002/img.png";
var outputPath = "E:/EDrive/Images/2016_12_07_18_27_16--Project002/imgshading1.png";
const MyJimp = configure({ plugins: [shadow] }, Jimp)
// You might be able to just call configure since it modifies the global jimp (I think)
configure({ plugins: [shadow] }, Jimp)
async function main() {
const image = await Jimp.read(inputPath);

try{
    image.boxShadow();
    image.write(outputPath, function (err2, info2) {
        console.log(info2);
     })
}
 catch (err) {
     console.error(err);
 }

}
main();

Output

image

@shmlkv

Still getting same error

Here is the sample complete code

const Jimp = require('jimp'); const configure = require('@jimp/custom'); const shadow = require('@jimp/plugin-shadow'); var inputPath = "E:/EDrive/Images/2016_12_07_18_27_16--Project002/img.png"; var outputPath = "E:/EDrive/Images/2016_12_07_18_27_16--Project002/imgshading1.png"; configure({ plugins: [shadow] }, Jimp); async function main() { const image = await Jimp.read(inputPath); try { image.boxShadow(); image.write(outputPath, function (err2, info2) { console.log(info2); }) } catch (err) { console.error(err); } } main();

@vinaymuthanna0727 the function is shadow not boxShadow

Sorry for the incorrect docs!

Its working now
Thank you so much .

Property 'shadow' does not exist on type 'JimpConstructors &

hmm'?

@SaliZumberi what version of Typescript are you using?

2.9 @crutchcorn

@SaliZumberi Can you share the code sample of how you're using Jimp? I wouldn't expect that error from TS 2.9 at all, as our typings don't have a JimpConstructors & in the typings version

I'm especially looking for how you're importing Jimp and using it

Nevermind, I've figured out the issue. Opening a PR to resolve

Anyone that's facing issues similar to @SaliZumberi should update to v0.9.7. This PR should fix the issues with TS usage

Was this page helpful?
0 / 5 - 0 ratings

Related issues

molipha picture molipha  路  6Comments

Favna picture Favna  路  4Comments

alyyousuf7 picture alyyousuf7  路  3Comments

haydenbleasel picture haydenbleasel  路  6Comments

maqboolkhan picture maqboolkhan  路  5Comments