Co-Authored-By: Andrew Calcutt <acalcutt@techidiots.net>
This commit is contained in:
parent
5a883d9db0
commit
c9bc1ec573
1 changed files with 24 additions and 16 deletions
|
@ -133,6 +133,7 @@ function createEmptyResponse(format, color, callback) {
|
|||
}
|
||||
|
||||
// create an "empty" response image
|
||||
try {
|
||||
color = new Color(color);
|
||||
const array = color.array();
|
||||
const channels = array.length === 4 && format !== 'jpeg' ? 4 : 3;
|
||||
|
@ -145,11 +146,18 @@ function createEmptyResponse(format, color, callback) {
|
|||
})
|
||||
.toFormat(format)
|
||||
.toBuffer((err, buffer, info) => {
|
||||
if (!err) {
|
||||
cachedEmptyResponses[cacheKey] = buffer;
|
||||
if (err) {
|
||||
console.error('Error creating image with Sharp:', err);
|
||||
callback(err, null);
|
||||
return;
|
||||
}
|
||||
cachedEmptyResponses[cacheKey] = buffer;
|
||||
callback(null, { data: buffer });
|
||||
});
|
||||
} catch (error) {
|
||||
console.error('Error during image processing setup:', error);
|
||||
callback(error, null);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue