Why are my resized images alway blurry?

1.9k views Asked by At

I'm using node.js and sharp to resize images that my users upload. They are always blurry. I have no idea why. Here is my code:

var sharp = require("sharp");

sharp(file.path)
    .resize(width, height).max()
    .toFormat('png')
    .toBuffer(next);
    ...

Resized image is blurry. What am I missing?

By the way, I'm resizing larger images down to a smaller size. The width and height are proportional to the original size. For example, if the original dimension were 600x300, then the width and height are, for example, 300x150. So, it's definitely not an issue with miscalculating the width and height. I've also tried the same thing using imageMagick and had the same issues. I always get a resized image, but it's very blurry.

1

There are 1 answers

0
Wilson Walker On

With ImageMagick I found that using filter: "Catrom" https://www.npmjs.com/package/gulp-image-resize/v/0.13.1 and sharpen: "-1.5x1+0.7+0.02" http://www.imagemagick.org/Usage/resize/#resize_unsharp works quite well when downsizing an image.