简体   繁体   English

ImageMagick 与 PowerShell 一起使用时抛出错误

[英]ImageMagick throws error when used with PowerShell

I basically want to take a line of text and output it as a .png file.我基本上想取一行文本并将其输出为.png文件。 This snippet here on its own works fine:这个片段本身就可以正常工作:

convert -background lightblue -fill blue -font Candice -pointsize 72 label:Anthony test.png

I have about 100 lines I need to process though, So I tried to do it through a loop, using PowerShell:我有大约 100 行需要处理,所以我尝试使用 PowerShell 通过循环来完成:

 $MGLTriggers = Get-Content -Path ".\MGl\MG_Config.txt" -TotalCount 100
 foreach ($CurItem in $MGLTriggers){
    $Path = Join-Path -Path "./mgl/" -ChildPath ($CurItem + ".png")
    convert -background lightblue -fill blue -font Candice -pointsize 72 label:$CurItem         $Path}

Convert.exe throws this error for all the items: Convert.exe 为所有项目抛出此错误:

convert.exe: no encode delegate for this image format `LABEL' @ error/constitute.c/WriteImage/1272.

I've searched everywhere and pulled fair amount of hair.我到处找,拉了相当多的头发。 What am I doing wrong?我究竟做错了什么? Any help would be appreciated.任何帮助,将不胜感激。

The following snippet runs on my environment without errors:以下代码段在我的环境中运行没有错误:

$ItemList = @(
    'John Lennon',
    'George Harrison',
    'Paul McCartney',
    'Ringo Starr'
) 

foreach ($Item in $ItemList) {
    $Path = Join-Path -Path 'D:\sample\empty' -ChildPath ($Item + '.png')
    & "C:\Program Files\ImageMagick-7.1.0-Q16-HDRI\convert.exe" -background "lightblue" -fill "blue" -font "consolas" -pointsize 72 label:"$Item" $Path
}

BTW: When you crosspost the same question at the same time to different forums you should at least post links to the other forums along with your question to avoid people willing to help you making their work twice or more.顺便说一句:当您同时将同一问题交叉发布到不同的论坛时,您至少应该将其他论坛的链接与您的问题一起发布,以避免有人愿意帮助您进行两次或更多次的工作。

Thanks in advcance ;-)提前致谢;-)

PowerShell.org Forum - ImageMagick throws error when used with PowerShell PowerShell.org 论坛 - ImageMagick 与 PowerShell 一起使用时抛出错误

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM