Added ability to resize and compress images on upload


I feel this is a bug but I prefer to double check with the community first.

From the release note:
:sparkles: Added ability to resize and compress images on upload (TryGhost/Ghost#9837)

I understand that on pic upload the system does:

  • Resizes uploaded image to 2000px width
  • Sets image quality to 80% when uploading a jpeg

I tried it with a picture of 2200px and the image is still 2200px once published and no compression was applied.

  • What’s your URL?
  • What version of Ghost are you using? 2.1.0
  • What configuration? I don’t understand the question :(
  • What browser? Chrome, mac high sierra
  • What errors or information do you see in the console? no error
  • What steps could someone else take to reproduce the issue you’re having? Upload a picture higher than 2001px

Technical details:

  • Ghost Version: 2.1.1 / CLI version: 1.9.3
  • Node Version: 8.11.4
  • Browser/OS: Alpine, Travis builds, Chrome 66, OS X 10.13.6
  • Database: sqlite


Idea — I feel this use case would be a good candidate to be an App. My settings would be:

width max size: 1440 px
compression level: 80%

It looks like Sharp integration by gargol · Pull Request #9837 was merged into Ghost 2.1.0. Now, there is an imageOptimization setting on the file core/server/config/defaults.json:

"imageOptimization": {
    "resize": true

See discussion at [Investigation] Image Processing & Manipulation · Issue #4453, and the related Automatic thumbnailing/resizing of image uploads - Ideas - Ghost Forum.

Juan, regarding to my original bug filling, do you consider it’s a bug or not?

I’ve not tried that new Ghost version yet but, do you have a sharp subfolder now in node_modules?

This is a file formatted as config.{environment}.json should be stored in the root directory of your ghost instance (if you have any overrides). In case you didn’t change anything the resizing should be configured to work out of the box.

We don’t provide custom width/compression level configurations just yet. The default is set to 2000 here - Sharp integration by naz · Pull Request #9837 · TryGhost/Ghost · GitHub , and compression level is 80% by default, so you don’t need to change anything :slight_smile:

Regarding config.production.json, I didn’t change anything.
That’s why I feel something is wrong as in the test I did, no resizing nor compression was applied.

Was sharp installed? ls -la node_modules/sharp?

1 Like

@pascalandy To make this absolutely clear, sharp is an optional binary dependency. This means that if it tries to install and fails (which it might do for many reasons - binary dependencies are tricky), Ghost carries on and falls back to not optimising images just like it did before.

This is why you’re being asked if sharp actually installed for you or not.


Thanks for jumping in @Kate and @Hannah

at /var/lib/ghost/versions/2.1.0/node_modules there is no sharp DIR.

If it helps, here is the complete build log of my installation:


I searched in the logs for the keyword ‘sharp’. There is nothing.

Should the node packager warn the user about the fact that ‘sharp’ could not be installed?

If so, I could write an automated test like this one :)

@pascalandy I think this is the pertinent line in your log:

[17:12:35] → [5/5] Building fresh packages...
[17:12:36] → info This module is OPTIONAL, you can safely ignore this error
[17:12:37] → Done in 18.51s.

Seems to suggest the optional module didn’t install. Maybe you have other logs from ghost-cli available to see what the error was?

Not at the moment.
What I’ll do is to introduce --verbose (ghost install --verbose) on build time and see if I can find something. I’ll follow up.

Same warning - Travis CI - Test and Deploy Your Code with Confidence

How should I use the ghost-cli log then ?

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