图像审核 firebase 函数的 ChildProcessError
ChildProcessError for image moderation firebase function
我正在尝试实施图像审核代码以删除此处给出的成人或暴力内容:https://github.com/firebase/functions-samples/tree/master/generate-thumbnail
但是每次我都收到这个错误:
ChildProcessError: Command failed: convert /tmp/test folder/yes.jpg -channel RGBA -blur 0x8 /tmp/test folder/yes.jpg
convert: unable to open image `/tmp/test': No such file or directory @ error/blob.c/OpenBlob/2712.
convert: no decode delegate for this image format `' @ error/constitute.c/ReadImage/501.
convert: unable to open image `folder/yes.jpg': No such file or directory @ error/blob.c/OpenBlob/2712.
convert: unable to open image `/tmp/test': No such file or directory @ error/blob.c/OpenBlob/2712.
convert: no decode delegate for this image format `' @ error/constitute.c/ReadImage/501.
convert: no images defined `folder/yes.jpg' @ error/convert.c/ConvertImageCommand/3210.
`convert /tmp/test folder/yes.jpg -channel RGBA -blur 0x8 /tmp/test folder/yes.jpg` (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:213:5)
at emitTwo (events.js:106:13)
at ChildProcess.emit (events.js:191:7)
at maybeClose (internal/child_process.js:877:16)
at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)
由于这一行:
// Blur the image using ImageMagick.
return exec(`convert ${tempLocalFile} -channel RGBA -blur 0x8 ${tempLocalFile}`);
还有一个帮助是什么是调节视频而不是图像的最佳方式,即如果我想检查上传的视频是否具有攻击性(成人或暴力)。
感谢任何帮助。
你有:
convert /tmp/test folder/yes.jpg -channel RGBA -blur 0x8 /tmp/test folder/yes.jpg
/tmp/test 在两个地方,只是一条路径。 ImageMagick 不会喜欢没有图像文件的路径。您已经拥有路径为 folder/yes.jpg 的输入和输出文件。这就是为什么你得到
unable to open image `/tmp/test': No such file or directory
也许你的意思是
convert /tmp/test/folder/yes.jpg -channel RGBA -blur 0x8 /tmp/test/folder/yes.jpg
或
convert /tmp/test/yes.jpg -channel RGBA -blur 0x8 /tmp/test/yes.jpg
或
convert folder/yes.jpg -channel RGBA -blur 0x8 folder/yes.jpg
看来您的变量替换或带有变量的代码不正确。
P.S。您真的要模糊 alpha 通道吗?使用 -channel RGBA 即可。如果您不想模糊 alpha 通道,请使用 -channel RGB。如果没有 -channel RGBA,您也可能会得到不同的结果。
感谢 fmw42 的帮助,这是一个愚蠢的错误。命令中的问题仅与空格有关,请尝试避免在文件夹名称中使用空格。无论如何,如果你仔细处理命令,比如:
return exec(`convert "${tempLocalFile}" -channel RGBA -blur 0x8 "${tempLocalFile}"`);
我正在尝试实施图像审核代码以删除此处给出的成人或暴力内容:https://github.com/firebase/functions-samples/tree/master/generate-thumbnail
但是每次我都收到这个错误:
ChildProcessError: Command failed: convert /tmp/test folder/yes.jpg -channel RGBA -blur 0x8 /tmp/test folder/yes.jpg
convert: unable to open image `/tmp/test': No such file or directory @ error/blob.c/OpenBlob/2712.
convert: no decode delegate for this image format `' @ error/constitute.c/ReadImage/501.
convert: unable to open image `folder/yes.jpg': No such file or directory @ error/blob.c/OpenBlob/2712.
convert: unable to open image `/tmp/test': No such file or directory @ error/blob.c/OpenBlob/2712.
convert: no decode delegate for this image format `' @ error/constitute.c/ReadImage/501.
convert: no images defined `folder/yes.jpg' @ error/convert.c/ConvertImageCommand/3210.
`convert /tmp/test folder/yes.jpg -channel RGBA -blur 0x8 /tmp/test folder/yes.jpg` (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:213:5)
at emitTwo (events.js:106:13)
at ChildProcess.emit (events.js:191:7)
at maybeClose (internal/child_process.js:877:16)
at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)
由于这一行:
// Blur the image using ImageMagick.
return exec(`convert ${tempLocalFile} -channel RGBA -blur 0x8 ${tempLocalFile}`);
还有一个帮助是什么是调节视频而不是图像的最佳方式,即如果我想检查上传的视频是否具有攻击性(成人或暴力)。
感谢任何帮助。
你有:
convert /tmp/test folder/yes.jpg -channel RGBA -blur 0x8 /tmp/test folder/yes.jpg
/tmp/test 在两个地方,只是一条路径。 ImageMagick 不会喜欢没有图像文件的路径。您已经拥有路径为 folder/yes.jpg 的输入和输出文件。这就是为什么你得到
unable to open image `/tmp/test': No such file or directory
也许你的意思是
convert /tmp/test/folder/yes.jpg -channel RGBA -blur 0x8 /tmp/test/folder/yes.jpg
或
convert /tmp/test/yes.jpg -channel RGBA -blur 0x8 /tmp/test/yes.jpg
或
convert folder/yes.jpg -channel RGBA -blur 0x8 folder/yes.jpg
看来您的变量替换或带有变量的代码不正确。
P.S。您真的要模糊 alpha 通道吗?使用 -channel RGBA 即可。如果您不想模糊 alpha 通道,请使用 -channel RGB。如果没有 -channel RGBA,您也可能会得到不同的结果。
感谢 fmw42 的帮助,这是一个愚蠢的错误。命令中的问题仅与空格有关,请尝试避免在文件夹名称中使用空格。无论如何,如果你仔细处理命令,比如:
return exec(`convert "${tempLocalFile}" -channel RGBA -blur 0x8 "${tempLocalFile}"`);