我正在尝试为通过eleventy-img运行的已处理图像指定输出目录。
const Image = require("@11ty/eleventy-img");
(async () => {
let url = "./img/home/";
let stats = await Image(url, {
widths: [300],
outputDir: "./img/processed/",
});
console.log(stats);
})();但是当我运行npx eleventy时,我得到的是这个错误消息
Unhandled rejection in promise ([object Promise]): (more in DEBUG output)
> Input file contains unsupported image format
`Error` was thrown:
Error: Input file contains unsupported image format它在没有指定outputDir选项的情况下工作得很好。下面是它的文档:https://www.11ty.dev/docs/plugins/image/#output-directory
没有使用它的实际示例,但从逻辑上讲,它应该以与widths参数相同的方式传递。
发布于 2021-04-26 22:28:07
我找到了我的错误。我试图用"./img/home/"传递整个文件夹。相反,我需要传递单独的图像,然后它才能工作。
如下所示:
const Image = require("@11ty/eleventy-img");
(async () => {
let url = "./img/home/my-image.jpg";
let stats = await Image(url, {
widths: [300],
outputDir: "./img/processed",
});
console.log(stats);
})();https://stackoverflow.com/questions/67268456
复制相似问题