I'm using sharp within a nodejs app to resize images. Sometimes when people upload images, it will always successfully save the main image, but then the resized images are sometimes saved as 0 bytes.
await temp.mv(path.resolve(folderName + name + '.' + extension))
.then((results) => {
sharp(folderName + name + '.' + extension)
.resize(150, 110, {
fit: 'cover'
})
.toFile(folderName + name + '-150x110' + '.' + extension, function(err) {
console.log(err);
})
sharp(folderName + name + '.' + extension)
.resize(350, 350, {
fit: 'cover'
})
.toFile(folderName + name + '-350x350' + '.' + extension, function(err) {
console.log(err);
})
sharp(folderName + name + '.' + extension)
.resize(385, 258, {
fit: 'cover'
})
.toFile(folderName + name + '-385x258' + '.' + extension, function(err) {
console.log(err);
})
})
Has anyone had problems with sharp in the past? I've never had any problems until recently, and the file sizes for the images aren't massive. I was wondering if it was a buffer problem, but I don't know why the images would be sometimes 0 bytes, it seems completely random. I can upload an image and get 5 quality resized images back, but sometimes you upload an image and get a couple that are 0 bytes.