Need to create an shading/shadow image.
Getting error on using image.boxShadow
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.
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.
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)
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");
})
});
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

@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 I'm especially looking for how you're importing Jimp and using itTS 2.9 at all, as our typings don't have a JimpConstructors & in the typings version
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
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);
}
main();
Output