代码之家  ›  专栏  ›  技术社区  ›  JoeManFoo

在云函数上运行convert命令会返回无法在本地再现的错误

  •  0
  • JoeManFoo  · 技术社区  · 7 年前

    ```

    let exec = require('child-process-promise').exec
    let magickCommand = `convert -background none -stroke "rgba(139, 184, 232, 1)" -fill "rgba(136, 183, 232, 0.83)" -font /tmp/1057522377634683-priceFont.ttf -pointsize 70 label:"$48" -trim ( +clone -background "rgba(135, 138, 140, 0.59)" -shadow 80x8+8+10 ) +swap -background none -layers merge +repage -rotate 0 -fuzz 10% -trim /tmp/1057522377634683-priceText.png`
    exec(magickCommand).then(() => { console.log('finished') })
    

    ``` 我可以在我的Windows计算机上本地运行,并具有匹配版本的 convert 与谷歌云功能一样:ImageMagick-6.8.9-9-Q16-x64-static

    在函数上运行相同的Imagemagick命令时,出现以下错误: ```

    { ChildProcessError: Command failed: convert -background none -stroke "rgba(139, 184, 232, 1)" -fill "rgba(136, 183, 232, 0.83)" -font /tmp/1057522377634683-priceFont.ttf -pointsize 90 label:"$48" -trim \( -clone -background "rgba(135, 138, 140, 0.59)" -shadow 80x8+8+10 \) +swap -background none -layers merge +repage -rotate 0 -fuzz 10% -trim /tmp/1057522377634683-priceText.png
    convert: image sequence is required `-clone' @ error/convert.c/ConvertImageCommand/967.
     `convert -background none -stroke "rgba(139, 184, 232, 1)" -fill "rgba(136, 183, 232, 0.83)" -font /tmp/1057522377634683-priceFont.ttf -pointsize 90 label:"$48" -trim \( -clone -background "rgba(135, 138, 140, 0.59)" -shadow 80x8+8+10 \) +swap -background none -layers merge +repage -rotate 0 -fuzz 10% -trim /tmp/1057522377634683-priceText.png` (exited with error code 1)
        at callback (/user_code/node_modules/child-process-promise/lib/index.js:33:27)
        at ChildProcess.exithandler (child_process.js:211:5)
        at emitTwo (events.js:106:13)
        at ChildProcess.emit (events.js:191:7)
        at maybeClose (internal/child_process.js:891:16)
        at Socket.<anonymous> (internal/child_process.js:342:11)
        at emitOne (events.js:96:13)
        at Socket.emit (events.js:188:7)
        at Pipe._handle.close [as _onclose] (net.js:497:12)
      name: 'ChildProcessError',
      code: 1,
      childProcess: 
       { ChildProcess: { [Function: ChildProcess] super_: [Object] },
         fork: [Function],
         _forkChild: [Function],
         exec: [Function],
         execFile: [Function],
         spawn: [Function],
         spawnSync: [Function: spawnSync],
         execFileSync: [Function: execFileSync],
         execSync: [Function: execSync] },
      stdout: '',
      stderr: 'convert: image sequence is required `-clone\' @ error/convert.c/ConvertImageCommand/967.\n' }
    

    ```

    本地和谷歌云功能中的节点版本为6.11.2

    当我在本地运行命令时,我会生成一个透明的。png文件 Google Drive folder with font and output .png file

    1 回复  |  直到 7 年前
        1
  •  1
  •   xenoid    7 年前

    如果我用label替换标签:“$48”,我会得到同样的错误(在Linux上):(即,没有生成任何内容)。给定起始“$”,有可能将$48解释为某个变量名,并生成一个空字符串。暂时更换/卸下$不难检查。在这种情况下,解决方案是转义$:\$(可能)。