Netmano93
Netmano93

Reputation: 85

ImageMagick throws error when used with PowerShell

I basically want to take a line of text and output it as a .png file. 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:

 $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: 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.

Upvotes: 0

Views: 184

Answers (1)

Olaf
Olaf

Reputation: 5232

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 advance ;-)

PowerShell.org Forum - ImageMagick throws error when used with PowerShell

Upvotes: 1

Related Questions