PowerShell and magick arguments

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
pr3sidentspence
Posts: 27
Joined: 2018-10-31T12:29:16-07:00
Authentication code: 1152

PowerShell and magick arguments

Post by pr3sidentspence » 2018-12-04T20:09:51-07:00

Version: ImageMagick 7.0.8-14 Q16 x64 2018-10-24

This might be a PowerShell question more than an IM question, but I'm having the most fun time trying to get a single magick command out of Powershell. My code:

Code: Select all

        [string]$bigFinale = ('temp2\{0}.jpg -chop {1}%x0 -gravity east -chop {2}%x0 output\{0}.jpg' -f $gapInfo[0], $gapPC1, $gapPC2)
        Write-Host magick.exe $bigFinale
        & magick $bigFinale 
The output from the Write-Host looks perfect:

Code: Select all

magick.exe temp2\B2E001-back.jpg -chop 2%x0 -gravity east -chop 5%x0 output\B2E001-back.jpg
...and if I copy and paste Write-Host's output to the command line and run it, it works perfectly. But the...

Code: Select all

 & magick $bigFinale
...causes the error:

Code: Select all

Error: Invalid argument or not enough arguments

Usage: magick.exe tool [ {option} | {image} ... ] {output_image}
Usage: magick.exe [ {option} | {image} ... ] {output_image}
       magick.exe [ {option} | {image} ... ] -script {filename} [ {script_args} ...]
       magick.exe -help | -version | -usage | -list {option}
It seems that Write-Host and & process my argument string differently. But unless there's an equivalent of ECHO ON, I don't even know how. I don't suppose magick has an echo what I asked you to do function?

Has anyone come across this before, and - if so - how did you solve it?

pr3sidentspence
Posts: 27
Joined: 2018-10-31T12:29:16-07:00
Authentication code: 1152

Re: PowerShell and magick arguments

Post by pr3sidentspence » 2018-12-04T20:50:12-07:00

Code: Select all

cmd.exe /c "magick.exe $bigFinale"
worked, basically endrunning the problem.

Post Reply