Need help writing DOS script

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
jonathanjohnson100
Posts: 7
Joined: 2014-05-04T18:43:18-07:00
Authentication code: 6789

Need help writing DOS script

Post 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
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Need help writing DOS script

Post 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/
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Need help writing DOS script

Post 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.
snibgo's IM pages: im.snibgo.com
Post Reply