首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >Nodejs和Jimp缩略图生成

Nodejs和Jimp缩略图生成
EN

Stack Overflow用户
提问于 2018-06-17 18:07:12
回答 1查看 1.1K关注 0票数 1

我使用了一个azure函数来使用jimp生成缩略图。我遇到的挑战是azure容器上的内容类型最终是application/octet-stream而不是image/jpeg。如何解决这个问题?

下面是代码:

代码语言:javascript
运行
复制
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);

                }

            });

    });

};
EN

回答 1

Stack Overflow用户

发布于 2018-06-17 18:51:07

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

目前,您必须退回到直接使用Storage SDK。有关示例,请参阅同一问题中的this comment

如果可以选择C#,请选中this example

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/50895611

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档