Skip to content

Instantly share code, notes, and snippets.

@taylorstine
Created March 11, 2017 15:25
Show Gist options
  • Select an option

  • Save taylorstine/5e5ddec20dadf4134885125f8cb19113 to your computer and use it in GitHub Desktop.

Select an option

Save taylorstine/5e5ddec20dadf4134885125f8cb19113 to your computer and use it in GitHub Desktop.
Resize with blur and quality
const makeResizer = (type:'contain'|'cover')=>(req, res) =>{
let resizer = sharp();
//....
const {quality, blur} = res.props;
if (blur) {
if (blur === true) {
resizer = resizer.blur()
} else {
resizer = resizer.blur(blur);
}
}
if (quality !== 100) {
resizer = resizer.jpeg({quality});
}
return resizer
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment