My scripts are breaking due to a change in the -verbose info
Posted: 2008-04-03T15:43:00-07:00
Hello,
Many of my scripts are breaking when I try to extract the min, max, mean and standard deviation from the -verbose info: for a grayscale image. (I found this with the current IM 6.4.0-3 running Q16-hdri). This appears to be due to a change in capitalization of these words in the -verbose info:
Currently they are reported as:
Channel statistics:
gray:
min: 7196 (0.109804)
max: 59881 (0.913725)
mean: 31955.3 (0.487606)
standard deviation: 12012.7 (0.183302)
But in previous versions of IM at least around and before IM 6.3.8-11, they were reported as:
Channel statistics:
gray:
Min: 7196 (0.109804)
Max: 59881 (0.913725)
Mean: 31955.3 (0.487606)
Standard deviation: 12012.7 (0.183302)
Note the words start with a capital letter and not the current lower case letter.
My scripts had been using the following sed commands to extract this information.
data=`convert $tmp2 -verbose info:`
min=`echo "$data" | sed -n '/^.*Min:.*[(]\([0-9.]*\).*$/{ s//\1/; p; q; }'`
[ "$min" = "" ] && errMsg "--- MIN NOT FOUND --- "
max=`echo "$data" | sed -n '/^.*Max:.*[(]\([0-9.]*\).*$/{ s//\1/; p; q; }'`
[ "$max" = "" ] && errMsg "--- MAX NOT FOUND --- "
mean=`echo "$data" | sed -n '/^.*Mean:.*[(]\([0-9.]*\).*$/{ s//\1/; p; q; }'`
[ "$mean" = "" ] && errMsg "--- MEAN NOT FOUND --- "
std=`echo "$data" | sed -n '/^.*Standard.*[(]\([0-9.]*\).*$/{ s//\1/; p; q; }'`
[ "$std" = "" ] && errMsg "--- STD NOT FOUND --- "
Now, I find this only works as:
data=`convert $tmp2 -verbose info:`
min=`echo "$data" | sed -n '/^.*min:.*[(]\([0-9.]*\).*$/{ s//\1/; p; q; }'`
[ "$min" = "" ] && errMsg "--- MIN NOT FOUND --- "
max=`echo "$data" | sed -n '/^.*max:.*[(]\([0-9.]*\).*$/{ s//\1/; p; q; }'`
[ "$max" = "" ] && errMsg "--- MAX NOT FOUND --- "
mean=`echo "$data" | sed -n '/^.*mean:.*[(]\([0-9.]*\).*$/{ s//\1/; p; q; }'`
[ "$mean" = "" ] && errMsg "--- MEAN NOT FOUND --- "
std=`echo "$data" | sed -n '/^.*standard.*[(]\([0-9.]*\).*$/{ s//\1/; p; q; }'`
[ "$std" = "" ] && errMsg "--- STD NOT FOUND --- "
where the key words are not first letter cap.
I want to update my scripts to trap on the exact minor version where this change has first occurred, so that I can support previous as well as current versions of IM. I also want to update my script with a version trap to use the new string formats, such as
convert image -format "%[mean]"
I believe this latter occurred at IM 6.3.9-1
So I would appreciate it if someone could confirm the latter and more important tell me at which minor release the capitalization change occurred.
Thanks
Fred
Many of my scripts are breaking when I try to extract the min, max, mean and standard deviation from the -verbose info: for a grayscale image. (I found this with the current IM 6.4.0-3 running Q16-hdri). This appears to be due to a change in capitalization of these words in the -verbose info:
Currently they are reported as:
Channel statistics:
gray:
min: 7196 (0.109804)
max: 59881 (0.913725)
mean: 31955.3 (0.487606)
standard deviation: 12012.7 (0.183302)
But in previous versions of IM at least around and before IM 6.3.8-11, they were reported as:
Channel statistics:
gray:
Min: 7196 (0.109804)
Max: 59881 (0.913725)
Mean: 31955.3 (0.487606)
Standard deviation: 12012.7 (0.183302)
Note the words start with a capital letter and not the current lower case letter.
My scripts had been using the following sed commands to extract this information.
data=`convert $tmp2 -verbose info:`
min=`echo "$data" | sed -n '/^.*Min:.*[(]\([0-9.]*\).*$/{ s//\1/; p; q; }'`
[ "$min" = "" ] && errMsg "--- MIN NOT FOUND --- "
max=`echo "$data" | sed -n '/^.*Max:.*[(]\([0-9.]*\).*$/{ s//\1/; p; q; }'`
[ "$max" = "" ] && errMsg "--- MAX NOT FOUND --- "
mean=`echo "$data" | sed -n '/^.*Mean:.*[(]\([0-9.]*\).*$/{ s//\1/; p; q; }'`
[ "$mean" = "" ] && errMsg "--- MEAN NOT FOUND --- "
std=`echo "$data" | sed -n '/^.*Standard.*[(]\([0-9.]*\).*$/{ s//\1/; p; q; }'`
[ "$std" = "" ] && errMsg "--- STD NOT FOUND --- "
Now, I find this only works as:
data=`convert $tmp2 -verbose info:`
min=`echo "$data" | sed -n '/^.*min:.*[(]\([0-9.]*\).*$/{ s//\1/; p; q; }'`
[ "$min" = "" ] && errMsg "--- MIN NOT FOUND --- "
max=`echo "$data" | sed -n '/^.*max:.*[(]\([0-9.]*\).*$/{ s//\1/; p; q; }'`
[ "$max" = "" ] && errMsg "--- MAX NOT FOUND --- "
mean=`echo "$data" | sed -n '/^.*mean:.*[(]\([0-9.]*\).*$/{ s//\1/; p; q; }'`
[ "$mean" = "" ] && errMsg "--- MEAN NOT FOUND --- "
std=`echo "$data" | sed -n '/^.*standard.*[(]\([0-9.]*\).*$/{ s//\1/; p; q; }'`
[ "$std" = "" ] && errMsg "--- STD NOT FOUND --- "
where the key words are not first letter cap.
I want to update my scripts to trap on the exact minor version where this change has first occurred, so that I can support previous as well as current versions of IM. I also want to update my script with a version trap to use the new string formats, such as
convert image -format "%[mean]"
I believe this latter occurred at IM 6.3.9-1
So I would appreciate it if someone could confirm the latter and more important tell me at which minor release the capitalization change occurred.
Thanks
Fred