Minor code improvements in image-runner.js

This commit is contained in:
SwanX1 2022-01-16 23:04:30 +02:00
parent dd5df2402c
commit ee01986479
No known key found for this signature in database
GPG Key ID: 870B49F9C0D2A762
1 changed files with 2 additions and 2 deletions

View File

@ -9,13 +9,13 @@ const magick = nodeRequire(`../build/${process.env.DEBUG && process.env.DEBUG ==
function run(object) {
return new Promise((resolve, reject) => {
// If the image has a path, it must also have a type
let promise = new Promise((resolveTest) => { resolveTest(); }); // no-op
let promise = Promise.resolve();
if (object.path) {
if (object.params.type !== "image/gif" && object.onlyGIF) resolve({
buffer: Buffer.alloc(0),
fileExtension: "nogif"
});
promise = fetch(object.path).then(res => res.arrayBuffer()).then(buf => { return Buffer.from(buf); });
promise = fetch(object.path).then(res => res.arrayBuffer()).then(buf => Buffer.from(buf));
}
// Convert from a MIME type (e.g. "image/png") to something ImageMagick understands (e.g. "png").
// Don't set `type` directly on the object we are passed as it will be read afterwards.