Portable version adding to Windows's Environmental Variables problem

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
FateTrader
Posts: 3
Joined: 2016-09-14T09:21:29-07:00
Authentication code: 1151

Portable version adding to Windows's Environmental Variables problem

Post by FateTrader »

Running a batch resizing an image which is inside the same folder as the ImageMagic files works. BUT I want to be able to use a batch file from outside the folder containing the ImageMagic files. Normally with other CMD programs I do this by adding a path within Windows's Environmental Variables and this works great, but with ImageMagic done this way it tells me: "Invalid Parameter - -resize" (which as I said the same batch file within the programs folder works fine)

Any idea why this happens?
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: Portable version adding to Windows's Environmental Variables problem

Post by Bonzo »

It is probably calling the windows program called convert and that does not have a resize option.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Portable version adding to Windows's Environmental Variables problem

Post by snibgo »

As Bonzo says. That message comes from the Microsoft program, not ImageMagick.

The cure is either to add IM's directory to your system path, or to always call "convert" with an explicit path.
snibgo's IM pages: im.snibgo.com
FateTrader
Posts: 3
Joined: 2016-09-14T09:21:29-07:00
Authentication code: 1151

Re: Portable version adding to Windows's Environmental Variables problem

Post by FateTrader »

Thank you very much guys explicit/absolute path solved the problem

instead of:

Code: Select all

for %%a in ("*.PNG") do convert.exe "%%a" -resize 1920x1080 "%%~na.PNG"
I have this now and this works well:

Code: Select all

for %%a in ("*.PNG") do "c:\Program Files (x86)\Batch Files\convert.exe" "%%a" -resize 1920x1080 "%%~na.PNG"
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Portable version adding to Windows's Environmental Variables problem

Post by snibgo »

That's it. But I suggest you use an environment variable for the path. Eg, have a system-wide variable called IM set to c:\Program Files (x86)\Batch Files\
and then call "%IM%convert".
snibgo's IM pages: im.snibgo.com
FateTrader
Posts: 3
Joined: 2016-09-14T09:21:29-07:00
Authentication code: 1151

Re: Portable version adding to Windows's Environmental Variables problem

Post by FateTrader »

snibgo wrote:That's it. But I suggest you use an environment variable for the path. Eg, have a system-wide variable called IM set to c:\Program Files (x86)\Batch Files\
and then call "%IM%convert".
This works great, thanks a lot!
Post Reply