gpt4 book ai didi

node.js - Nodejs 和 Jimp 缩略图生成

转载 作者:太空宇宙 更新时间:2023-11-04 00:08:56 31 4
gpt4 key购买 nike

我正在使用 azure 函数通过 jimp 生成缩略图。我面临的挑战是天蓝色容器上的内容类型最终是 application/octet-stream 而不是 image/jpeg。怎么解决这个问题呢?

这是代码:

var Jimp = require("jimp");

module.exports = (context, myBlob) => {

// Read image with Jimp
Jimp.read(myBlob).then((image) => {

// Manipulate image
image
.resize(200, 200)

.getBuffer( Jimp.MIME_JPEG, (error, stream) => {

// Check for errors
if (error) {
context.log(`There was an error processing the image.`);
context.done(error);
}
else {

context.log(`Successfully processed the image`);

context.bindingData.properties = {contentType: Jimp.MIME_JPEG}

// Bind the stream to the output binding to create a new blob
context.done(null, stream);

}

});

});

};

最佳答案

不幸的是,Blob 输出绑定(bind)目前不支持设置内容类型。请参阅Blob bindings can't set ContentType and other properties跟踪进度。

目前,您必须转而直接使用存储 SDK。请参阅this comment以同一期为例。

如果可以选择 C#,请检查 this example .

关于node.js - Nodejs 和 Jimp 缩略图生成,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50895611/

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