Page 1 of 1

Mogrify -resize works in cmd.exe but not in .bat file

Posted: 2014-02-18T04:07:07-07:00
by visitor x
If i do it manually with cmd.exe mogrify works a charm.

However, when I run it from a .bat file it fails. I tried some with convert too just in case but no joy. The error code is always The command "mogrify" is missing or not found.

I thought I had found the answer here but as my images are being created and the active directory is where I want it I don't see how that could be the issue.

I have opened a console, cd to the new directory created by the above, copied and pasted one of the below mogrify commands and it works fine.

So I reckon it's either down to a difference between cmd and bat that I'm not aware of or something in imagemagick. Either way I'm new to both so hoping someone can help me.

Code is as follows:

Code: Select all

set path=icons %date:~0% %time:~0,2%_%time:~3,2%_%time:~6,2%\
md "%path%"
cd %path%

copy %1 "ios_144x144.png"
copy %1 "android_ldpi.png"
copy %1 "android_mdpi.png"
copy %1 "android_hdpi.png"
copy %1 "android_xhdpi.png"
copy %1 "ios_57x57.png"
copy %1 "ios_72x72.png"
copy %1 "ios_114x114.png"
copy %1 "ios_144x144.png"

pause //Check here to see if dir and images created and that command line is now in %path%. In test runs all is okay as far as here

convert -resize 36x36 android_ldpi.png
mogrify -resize 48x48 android_mdpi.png
mogrify -resize 72x72 android_hdpi.png
mogrify -resize 96x96 android_xhdpi.png
mogrify -resize 114x114 ios_114x114.png
mogrify -resize 144x144 ios_144x144.png
mogrify -resize 72x72 ios_72x72.png
mogrify -resize 57x57 ios_57x57.png


echo Verzeichnis %path% fertig.

pause>nul

Re: Mogrify -resize works in cmd.exe but not in .bat file

Posted: 2014-02-18T04:17:52-07:00
by snibgo
What version of Windows are you running? What version of IM?

At the command prompt, type

Code: Select all

where mogrify.exe
What is the result?

Also put that line in the bat file. What is the result?

Re: Mogrify -resize works in cmd.exe but not in .bat file

Posted: 2014-02-18T04:20:41-07:00
by snibgo
EDIT: the problem is:

Code: Select all

set path=icons %date:~0% %time:~0,2%_%time:~3,2%_%time:~6,2%\
This wipes out your path! Windows will no longer be able to find programs in their usual places.

Call it something different, eg "mypath".

Re: Mogrify -resize works in cmd.exe but not in .bat file

Posted: 2014-02-18T04:23:14-07:00
by visitor x
snibgo wrote:What version of Windows are you running? What version of IM?

Windows 7, ImageMagick-6.8.8-Q16

At the command prompt, type

Code: Select all

where mogrify.exe
What is the result?

C:\Program Files\ImageMagick-6.8.8-Q16\mogrify.exe is the result. My env var is also set to here

Also put that line in the bat file. What is the result?
C:\Program Files\ImageMagick-6.8.8-Q16\mogrify.exe

Re: Mogrify -resize works in cmd.exe but not in .bat file

Posted: 2014-02-18T04:24:55-07:00
by visitor x
snibgo wrote:EDIT: the problem is:

Code: Select all

set path=icons %date:~0% %time:~0,2%_%time:~3,2%_%time:~6,2%\
This wipes out your path! Windows will no longer be able to find programs in their usual places.

Call it something different, eg "mypath".
Thank you!!!!!! Egg and my face, same trajectory!