亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

w 和 h 必須是數字

w 和 h 必須是數字

幕布斯6054654 2021-09-17 10:25:44
我很難重新創建這個例子。我得到以下輸出: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 的值是一個字符串,而不是一個數字。

http://img1.sycdn.imooc.com//6143fcc50001329d06510451.jpg

http://img1.sycdn.imooc.com//6143fcd000010aeb02560111.jpg

試試 const widthInPixels = Number(process.env.THUMBNAIL_WIDTH);


查看完整回答
反對 回復 2021-09-17
  • 1 回答
  • 0 關注
  • 179 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號