Co-Authored-By: Andrew Calcutt <acalcutt@techidiots.net>
This commit is contained in:
acalcutt 2024-12-29 01:56:15 -05:00
parent 5a883d9db0
commit c9bc1ec573

View file

@ -133,6 +133,7 @@ function createEmptyResponse(format, color, callback) {
} }
// create an "empty" response image // create an "empty" response image
try {
color = new Color(color); color = new Color(color);
const array = color.array(); const array = color.array();
const channels = array.length === 4 && format !== 'jpeg' ? 4 : 3; const channels = array.length === 4 && format !== 'jpeg' ? 4 : 3;
@ -145,11 +146,18 @@ function createEmptyResponse(format, color, callback) {
}) })
.toFormat(format) .toFormat(format)
.toBuffer((err, buffer, info) => { .toBuffer((err, buffer, info) => {
if (!err) { if (err) {
cachedEmptyResponses[cacheKey] = buffer; console.error('Error creating image with Sharp:', err);
callback(err, null);
return;
} }
cachedEmptyResponses[cacheKey] = buffer;
callback(null, { data: buffer }); callback(null, { data: buffer });
}); });
} catch (error) {
console.error('Error during image processing setup:', error);
callback(error, null);
}
} }
/** /**