您必须在“%”运算符后提供一个值表达式
You must provide a value expression following the '%' operator
PS C:\ImageMagick> convert -background transparent -fill hsb(0%,0%,0%) -font Arial -pointsize 18 -size 18x26 -gravity center label:p "output2.png"
At line:1 char:51
+ convert -background transparent -fill hsb(0%,0%,0%) -font Arial -pointsize 18 -s ...
+ ~
You must provide a value expression following the '%' operator.
+ CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : ExpectedValueExpression
上面的命令在 cmd window 中运行没有任何问题,但在 PowerShell 中以红色文本抛出错误,我已经在上面粘贴了。看了很多文章,还没找到好的解决办法。
我想也许他们在谈论对 hsb
的调用,我用引号将其括起来:
PS C:\ImageMagick> convert -background transparent -fill "hsb(0%,0%,0%)" -font Arial -pointsize 18 -size 18x26 -gravity center label:p "output2.png"
Invalid Parameter - transparent
这只会导致另一个问题。我尝试在命令前加上 &
前缀,这是我以前不熟悉的一种技术,但似乎没有解决任何问题。
PowerShell 将括号解释为分组表达式,因此它认为内部的 % 是余数(模数)运算符。您可以使用停止解析运算符 --%
让 PowerShell 以 'dumb' 模式进行解析,例如:
convert.exe --% -background transparent -fill hsb(0%,0%,0%) -font Arial -pointsize 18 -size 18x26 -gravity center label:p "output2.png"
PowerShell 不使用当前目录作为查找命令的宫殿。所以 convert
被解析为 C:\Windows\System32\convert.exe
Get-Command convert|ft CommandType,Name,Definition
# CommandType Name Definition
# ----------- ---- ----------
# Application convert.exe C:\Windows\System32\convert.exe
如果您想从当前目录调用 convert.exe
,请使用 .\convert
而不是 convert
。
PS C:\ImageMagick> convert -background transparent -fill hsb(0%,0%,0%) -font Arial -pointsize 18 -size 18x26 -gravity center label:p "output2.png"
At line:1 char:51
+ convert -background transparent -fill hsb(0%,0%,0%) -font Arial -pointsize 18 -s ...
+ ~
You must provide a value expression following the '%' operator.
+ CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : ExpectedValueExpression
上面的命令在 cmd window 中运行没有任何问题,但在 PowerShell 中以红色文本抛出错误,我已经在上面粘贴了。看了很多文章,还没找到好的解决办法。
我想也许他们在谈论对 hsb
的调用,我用引号将其括起来:
PS C:\ImageMagick> convert -background transparent -fill "hsb(0%,0%,0%)" -font Arial -pointsize 18 -size 18x26 -gravity center label:p "output2.png"
Invalid Parameter - transparent
这只会导致另一个问题。我尝试在命令前加上 &
前缀,这是我以前不熟悉的一种技术,但似乎没有解决任何问题。
PowerShell 将括号解释为分组表达式,因此它认为内部的 % 是余数(模数)运算符。您可以使用停止解析运算符 --%
让 PowerShell 以 'dumb' 模式进行解析,例如:
convert.exe --% -background transparent -fill hsb(0%,0%,0%) -font Arial -pointsize 18 -size 18x26 -gravity center label:p "output2.png"
PowerShell 不使用当前目录作为查找命令的宫殿。所以 convert
被解析为 C:\Windows\System32\convert.exe
Get-Command convert|ft CommandType,Name,Definition
# CommandType Name Definition
# ----------- ---- ----------
# Application convert.exe C:\Windows\System32\convert.exe
如果您想从当前目录调用 convert.exe
,请使用 .\convert
而不是 convert
。