Created
March 11, 2017 15:25
-
-
Save taylorstine/5e5ddec20dadf4134885125f8cb19113 to your computer and use it in GitHub Desktop.
Resize with blur and quality
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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