我很难重新创建这个例子。我得到以下输出: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);};我究竟做错了什么?为什么我会收到此异常?
1 回答
料青山看我应如是
TA贡献1772条经验 获得超8个赞
就像@Pointy 指出的那样, process.env.THUMBNAIL_WIDTH 的值是一个字符串,而不是一个数字。
试试 const widthInPixels = Number(process.env.THUMBNAIL_WIDTH);
添加回答
举报
0/150
提交
取消