1

I am using Express to serve resized images. Which Node.js package should be used to resize the image? I've seen a lot of packages that change the image and save it as a file, but I need to change the image and write data to response. Example:

package.compress('/path/to/image.png', 
    {width: 100px, height: 100px}, 
    function(result) {
        res.end(result);
});
roland
  • 7,135
  • 6
  • 42
  • 60
Vladimir37
  • 488
  • 1
  • 5
  • 19
  • If I understood correctly you want to compress the image when serving it to the client. I use [compression](https://www.npmjs.com/package/compression) which gzip's the resources when serving them, though this is not optimal for images since there are more advanced optimization techniques applicable (like [imagemin](https://www.npmjs.com/package/imagemin)). I'm not sure you would want to use that when serving, since it's a demanding operation (it can take seconds or even minutes for a single image). What is your use case? – Razvan Oct 31 '15 at 17:36
  • @razvan I want to show image-preview to users. But previews should be generated when the query without saving. – Vladimir37 Oct 31 '15 at 17:47
  • Then you should have a look at [this](http://stackoverflow.com/questions/4459379/preview-an-image-before-it-is-uploaded) – Razvan Oct 31 '15 at 18:47

1 Answers1

1

I chosen thumb-express (https://www.npmjs.com/package/thumb-express). This is what I need.

Vladimir37
  • 488
  • 1
  • 5
  • 19