问题
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
The command above which works without any trouble in a cmd window is throwing an error coming out in red text in PowerShell, which I have pasted above. I looked at a number of articles but have not come up with a good solution yet.
I though perhaps they were talking about the call to hsb which I surrounded in quotations:
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
that just leads to a different problem. I have tried prefixing the command with &, which is a technique I had been previously unfamiliar but that did not seem to solve anything.
回答1:
PowerShell does not use current directory as palace for looking for commands. So convert is resolved to C:\Windows\System32\convert.exe
Get-Command convert|ft CommandType,Name,Definition
# CommandType Name Definition
# ----------- ---- ----------
# Application convert.exe C:\Windows\System32\convert.exe
If you want to invoke convert.exe from current directory use .\convert instead of convert.
回答2:
PowerShell is interpreting the parens as a grouping expression so it thinks the % inside is the remainder (modulus) operator. You can get PowerShell to parse in kind of a 'dumb' mode with the stop parsing operator --% e.g.:
convert.exe --% -background transparent -fill hsb(0%,0%,0%) -font Arial -pointsize 18 -size 18x26 -gravity center label:p "output2.png"
来源:https://stackoverflow.com/questions/31237987/you-must-provide-a-value-expression-following-the-operator