Usage of value returned by 'identify' utility of ImageMagick in CMD

837 views Asked by At

A start of the line

identify -format %w input.jpg

in Command Prompt leads to printing of the width of the image.

I have to assign this value to some variable within a CMD-file in order to use this variable further in the script. How can I do this?

I need some code like this:

@echo OFF  
set width=identify -format %w input.jpg
rem ...further usage of %width%...

However, it doesn't work.

P.S.: The code presented in this answer is almost what I need, but I need a code for the CMD-script.

1

There are 1 answers

1
Endoro On BEST ANSWER

you might try this:

for /f %%a in ('identify -format %%w input.jpg') do set "width=%%~a"
echo %width%