# ImageMagick throws error when used with PowerShell

**URL:** <https://forums.powershell.org/t/imagemagick-throws-error-when-used-with-powershell/17189>\
**Category:** PowerShell Help\
**Created:** [July 29, 2021, 9:30pm UTC](https://forums.powershell.org/t/imagemagick-throws-error-when-used-with-powershell/17189 "2021-07-29T21:30:22Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![powershelluser1267](https://avatars.discourse-cdn.com/v4/letter/p/c2a13f/32.png) [@powershelluser1267](https://forums.powershell.org/u/powershelluser1267)\
**Post date:** [July 29, 2021, 9:30pm UTC](https://forums.powershell.org/t/imagemagick-throws-error-when-used-with-powershell/17189/1 "2021-07-29T21:30:22Z")

</div>

I basically want to take a line of text and output it as a `.png` file. This snippet here on its own works fine:

```auto
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:

```auto
 $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:

```auto
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.

Note: This question is also Crossposted [here](https://stackoverflow.com/questions/68582986/imagemagick-throws-error-when-used-with-powershell)

---

<div class="post-metadata">

**Author:** ![Olaf](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/olaf/32/992_2.png) [@Olaf](https://forums.powershell.org/u/Olaf)\
**Post date:** [July 29, 2021, 11:41pm UTC](https://forums.powershell.org/t/imagemagick-throws-error-when-used-with-powershell/17189/2 "2021-07-29T23:41:46Z")

</div>

The following runs in my environment without errors:

```auto
$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
}

```

I just had to use another font because I don’t have a font named `Candice`. 😉

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.

[https://stackoverflow.com/questions/68582986/imagemagick-throws-error-when-used-with-powershell](https://stackoverflow.com/questions/68582986/imagemagick-throws-error-when-used-with-powershell)

---

<div class="post-metadata">

**Author:** ![dotnVo](https://avatars.discourse-cdn.com/v4/letter/d/4af34b/32.png) [@dotnVo](https://forums.powershell.org/u/dotnVo)\
**Post date:** [May 16, 2024, 8:22pm UTC](https://forums.powershell.org/t/imagemagick-throws-error-when-used-with-powershell/17189/3 "2024-05-16T20:22:57Z")

</div>


