我很难重新创建这个例子。我得到以下输出:
2019-08-19T17:19:24.531 [信息] 正在执行“Functions.PdfToTiffConverter”(原因='EventGrid 触发器在 2019-08-19T17:19:24.4859961+00:00'-f9552000'-f95525520 -a9ca7e0daf91) 2019-08-19T17:20:26.112 [信息] 错误:w 和 h 必须是 Jimp.throwError 处的数字 (D:\home\site\wwwroot\node_modules@jimp\utils\dist\index.js:26 :13) 在 Jimp.resize (D:\home\site\wwwroot\node_modules@jimp\plugin-resize\dist\index.js:38:36) 在 Jimp.read.then (D:\home\site\wwwroot \PdfToTiffConverter\index.js:14:19)
这是我的function.json:
{
"disabled": false,
"bindings": [
{
"type": "eventGridTrigger",
"name": "myEvent",
"direction": "in"
},
{
"name": "myBlob",
"type": "blob",
"direction": "in",
"path": "{data.url}",
"connection": "AZURE_STORAGE_CONNECTION_STRING",
"datatype": "binary"
}
]
}
这是我正在使用的代码:
const stream = require('stream');
const Jimp = require('jimp');
const storage = require('azure-storage');
const blobService = storage.createBlobService();
module.exports = (context, myEvent, myBlob) => {
const widthInPixels = process.env.THUMBNAIL_WIDTH;
const blobName = myEvent.subject.split('/')[6];
Jimp.read(myBlob).then((thumbnail) => {
thumbnail.resize(widthInPixels, Jimp.AUTO);
thumbnail.getBuffer(Jimp.MIME_PNG, (err, buffer) => {
const readStream = stream.PassThrough();
readStream.end(buffer);
blobService.createBlockBlobFromStream('thumbnails', blobName, readStream, buffer.length, (err) => {
context.done();
});
});
}).catch(context.log);
};
我究竟做错了什么?为什么我会收到此异常?
料青山看我应如是
相关分类