snibgo's Ims ImageMagick pages

Windows FOR

The Windows "For" command is useful for extracting values from ImageMagick.

For example:

FOR /F "usebackq" %%L ^
IN (`%IM%convert %1 %2 %3 %4 %5 %6 %7 %8 %9 -format "M_R=%%[fx:mean.r]\nM_G=%%[fx:mean.g]\nM_B=%%[fx:mean.b]" info:`) ^
DO set %%L

This executes convert once. Convert reads the image given by %1..%9, and spits out three lines. The "for" command prepends "set" to each line, and executes it. The overall effect is to set three environment variables. If the command is pasted to a file named getFracs.bat, then:

call getFracs rose: -crop 10%x10%+0+0

results in:

set M_R=0.191261
set M_G=0.180728
set M_B=0.173669

Page version v1.0 18-Apr-2014.

Page created 14-Oct-2015 05:16:02.

Copyright © 2015 Alan Gibson.