gpt4 book ai didi

javascript - 使用 jimp 在 Node.js 中调整图像大小并获取新图像的路径

转载 作者:搜寻专家 更新时间:2023-11-01 00:39:48 37 4
gpt4 key购买 nike

我在 node.js 中使用 jimp 调整图像大小,我成功地降低了图像质量,但有点困惑如何获取新图像的路径

Jimp.read("test.jpg", function (err, test) {
if (err) throw err;
test.resize(256, 256)
.quality(50)
.write("new.jpg");
});

最佳答案

尝试类似的东西:

Jimp.read("test.jpg", function (err, test) {
if (err) throw err;
test.resize(256, 256)
.quality(50)
.write(__dirname + "./new.jpg");
});

这会将文件保存到您的项目根目录。

有关 __dirname 的更多信息

关于javascript - 使用 jimp 在 Node.js 中调整图像大小并获取新图像的路径,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38691318/

37 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com