@paroicms/server-image-cache-engine
Version:
The image variant engine that we use at Paroi.
24 lines • 942 B
JavaScript
import { createAsyncQueue } from "@paroi/async-lib";
import sharp from "sharp";
export let sharpQueue = execImmediately;
export function setupImageProcessor({ cpuCoresPerFile, allowConcurrency, logger, }) {
const oldValue = sharp.concurrency();
if (cpuCoresPerFile !== undefined) {
// https://sharp.pixelplumbing.com/api-utility#concurrency
sharp.concurrency(cpuCoresPerFile);
logger.debug(`Set sharp concurrency (cpu cores per file) to '${cpuCoresPerFile}' (was ${oldValue})`);
}
else if (oldValue > 1) {
logger.debug(`Use the sharp concurrency (cpu cores per file) default value: ${oldValue}`);
}
if (!allowConcurrency) {
sharpQueue = createAsyncQueue({
delayMs: 50,
});
logger.debug(`Mode "one image processing at a time" is enabled`);
}
}
function execImmediately(task) {
return task();
}
//# sourceMappingURL=image-processor-setup.js.map