I'm creating the server for an ecommerce web app, and I cannot seem to resize the images into a perfect square. Is it that I need a set width and height to make it a perfect square?
Asked
Active
Viewed 1,082 times
1 Answers
2
According to the sharp API documentation, the resize method can accept an optional "fit" parameter that would be useful.
See https://sharp.pixelplumbing.com/api-resize
That would give something like :
sharp(input)
.resize({width:512, height:512, fit:"cover"})
.toBuffer()
.then(data => {
// ... do something with data
})

Christophe Maillot
- 183
- 1
- 7