jimp-dev / jimp

An image processing library written entirely in JavaScript for Node, with zero external or native dependencies.
http://jimp-dev.github.io/jimp/
MIT License
14.07k stars 761 forks source link

TypeError: Jimp.read is not a function #1350

Open syomna opened 1 month ago

syomna commented 1 month ago

I expect to be able to use the Jimp.read() function to load and manipulate images without encountering an error. The Jimp.read() function is throwing a Jimp.read is not a function error, and I'm unable to proceed with loading images.

>    <rejected> TypeError: Jimp.read is not a function
>        at processImageWithCorrections (/Users/yomna/Coding/Mobile Apps/Work/wright/functions/services/services.js:86:30)
>        at /Users/yomna/Coding/Mobile Apps/Work/wright/functions/index.js:41:28
>        at async runFunction (/Users/yomna/.nvm/versions/node/v18.20.4/lib/node_modules/firebase-tools/lib/emulator/functionsEmulatorRuntime.js:506:9)
>        at async runHTTPS (/Users/yomna/.nvm/versions/node/v18.20.4/lib/node_modules/firebase-tools/lib/emulator/functionsEmulatorRuntime.js:531:5)
>        at async /Users/yomna/.nvm/versions/node/v18.20.4/lib/node_modules/firebase-tools/lib/emulator/functionsEmulatorRuntime.js:694:21
  1. Install Jimp version 1.6.0 using npm.
  2. Use the following code to load an image:

    const Jimp = require('jimp');
    
    Jimp.read(imageUrl)
     .then(image => {
       // manipulate image
     })
     .catch(err => {
       console.error(err);
     });
  3. Run the script and observe the error: Jimp.read is not a function.
DanielOrtel commented 1 month ago

const {Jimp} = require('jimp')

Jimp no longer exposes a default export. See: https://jimp-dev.github.io/jimp/guides/migrate-to-v1/