Page 1 of 1

Need help writing DOS script

Posted: 2014-05-04T18:53:25-07:00
by jonathanjohnson100
I want to make a DOS script to do the following to images

- make square
- reduce size

I'm not sure where to start. I haven't been able to get to the second part

I did some googling and believe this will give me the width:

Code: Select all

w=`identify -format "%w" image.png`
(Similar for height)

If height is smaller, the crop the width of the image left and right to make the width be the same
Do similar if width is smaller

When I try the following, I get an error saying missing operator

Code: Select all

set /a w=`identify -format "%w" bmw.png`
Same if I do this:

Code: Select all

set /a w=identify -format "%w" bmw.png
(Leaving out the backtics)

Anyone know where I'm going wrong?

Thanks


JJ

Re: Need help writing DOS script

Posted: 2014-05-04T19:41:42-07:00
by fmw42
w=`identify -format "%w" image.png`
This is Unix format for getting variables. You will need help from one of the Windows users to convert this to Windows format. Or see http://www.imagemagick.org/Usage/windows/

Re: Need help writing DOS script

Posted: 2014-05-05T01:36:33-07:00
by snibgo
My usual way of getting width and height in Windows BAT is:

Code: Select all

FOR /F "usebackq" %%L IN (`identify -format "WW=%%w\nHH=%%h" %SRC%`) DO set %%L
See my pages for many examples of scripting IM in Windows.