Installing JIMP breaks the Ghost Blog

Hello, I am creating a custom storage module for Ghost (to use on my website) for the functionality of sending scaled images to the user. But as soon as I run the command:

npm install --save jimp

The Ghost blog breaks, currently I am running Ghost locally, but here is a screenshot of the error I get after installing the JIMP (JavaScript Image Manipulation Program) npm module.

To reproduce the same error, download a fresh zip of Ghost version 2.1.4 and run the following commands:

npm install
knex-migrator init
npm start

And, after completing the web setup by visiting http://localhost:2368/ghost, stop the Ghost, if running and try installing JIMP by running the above command.
Also, it looks like Ghost is installing Sharp npm module by default, my question is why does Ghost use Sharp for image manipulation rather than Jimp which is pure JavaScript and has no dependencies?

Thank you :)

If you’re creating a storage adapter, you should treat this as a package and install your dependencies locally to that package, rather than trying to add dependencies directly to Ghost.

I assume that the issue you’re encountering is npm choking on resolving sub-dependencies properly. We recommend using yarn instead, and doing that by relying on Ghost CLI for installing Ghost, unless you’re actively editing core, which you should not need to do.

As for Jimp vs Sharp

  1. jimp doesn’t have all the image manipulation features we want (it doesn’t do exif stripping)
  2. native image manipulate is assumed to be better than using pure js, given that Sharp has node gyp to aid with the install process.
  3. sharp has better marketing around it

Always interested in real world tests or stats that prove otherwise though.

Thanks for the reply, I would be happy if you could share your opinion on a YouTube playlist I am making on Ghost.

I want my blog website to be hosted using Ghost, I could do HTML minification, etc to make the website faster, except serving scaled images. Is there any chance that in near-future serving scaled images will be implemented in Ghost?

You can achieve this currently using Cloudinary Fetch:

but yes we plan to implement scaled images in Ghost core at some point :slight_smile:

But, what is your opinion on the YouTube playlist?

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.