I tried to install the plugin 'jimp/plugin-threshold', and then I followed the instruction provided by
https://github.com/oliver-moran/jimp/tree/master/packages/plugin-threshold. invoking method of 'image.threshold({ max: 150 });' will simply produce an error:
TypeError: image.threshold is not a function
at Jimp.read (/Users/Gangdooz/private/Web/NoSmoke/temp/playground.js:23:11)
at Timeout._onTimeout (/Users/Gangdooz/private/Web/NoSmoke/node_modules/@jimp/core/dist/index.js:331:25)
at ontimeout (timers.js:466:11)
at tryOnTimeout (timers.js:304:5)
at Timer.listOnTimeout (timers.js:267:5)
Version Info:
@jimp/[email protected]
[email protected]
looking at the docs it is not immediately obvious that you have to use @jimp/custom also! Sorry about that.
Try something like following:
const Jimp = require('jimp')
const threshold = require('@jimp/plugin-threshold')
const configure = require('@jimp/custom')
const MyJimp = configure({ plugins: [threshold] }, Jimp)
// You might be able to just call configure since it modifies the global jimp (I think)
configure({ plugins: [threshold] }, Jimp)
Thanks, I found out the document for this. Yes, the code above works 👍
@hipstersmoothie Thanks! Took me a while to find this, I then found this link:
https://github.com/oliver-moran/jimp/tree/master/packages/custom
Would probably be good to link this the “Extra Plugins” section of the readme?
Most helpful comment
looking at the docs it is not immediately obvious that you have to use
@jimp/customalso! Sorry about that.Try something like following: