cmdimagemagickcallexternalidentify

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


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.


Solution

  • you might try this:

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