Hello, I'm relatively new to using bc so I could use some help. In this script im working on I want to have the bc function to calculate float numbers for imagemagicks convert charcoal. Below is what I'm talking about. There are no syntax errors but when it outputs the users frames for example 0-10 the filter remains at an integer value. I want the filter to integrate with bc. I appreciate all help I can get. Thank you.
count=$START
SETSTEPS=$ (echo "scale=1; 1/25" | bc)
SETTING=$SETSTEPS
echo $SETSTEPS
while [ $count -le $END ];
do
#echo $count
#set for padding of 4 from 0-999.
if [ $count -lt 10 ]; then
convert ${IMGDIR}${IMG} -charcoal $count ${OUTDIR}${OUT}.000$count.jpg
fi
if [ $count -ge 10 ] && [ $count -le 99 ]; then
convert ${IMGDIR}${IMG} -charcoal $count ${OUTDIR}${OUT}.00$count.jpg
fi
if [ $count -ge 100 ] ; then
convert ${IMGDIR}${IMG} -charcoal $count ${OUTDIR}${OUT}.0$count.jpg
fi
SETTING=$(echo "scale=4; $SETTING+$SETSTEPS" | bc)
echo "processing frame: $count"
let count=count+1
# to view in maya's fcheck plugin
#fcheck -n $START $END 1 ${OUTDIR}${OUT}.@@.jpg
done
Looks like you need to specify 2 decimal places:
$ echo "scale=1;1/25" | bc
0
$ echo "scale=2;1/25" | bc
.04
$
Hey I changed a few things around and the setting for which the values to change are working as they should now. I still don't understand where I'm going wrong to make the filter integrate with those values. Without the bc the filter on the image sequence is the same as it is with the bc command.
count=$START
SETSTEPS=$(echo "scale=2; 1/2" | bc)
SETTING=$SETSTEPS
while [ $count -le $END ];
do
echo $count
#set for padding of 4 from 0-999.
if [ $count -lt 10 ]; then
convert ${IMGDIR}${IMG} -charcoal $count ${OUTDIR}${OUT}.000$count.jpg
fi
if [ $count -ge 10 ] && [ $count -le 99 ]; then
convert ${IMGDIR}${IMG} -charcoal $count ${OUTDIR}${OUT}.00$count.jpg
fi
if [ $count -ge 100 ] ; then
convert ${IMGDIR}${IMG} -charcoal $count ${OUTDIR}${OUT}.0$count.jpg
fi
SETTING=$(echo "scale=2; $SETTING+$SETSTEPS" | bc)
echo "processing frame: "$count " setting is: " $SETTING "setsteps is " $SETSTEPS""
let count=count+1
This is from the terminal. I want this math to integrate with the filter output of the image. Basically the image goes lighter to darker over time, I want it to get darker at a slower rate. I know 1/2 wont do that but this is just an example.
processing frame: 0 setting is: 1.00 setsteps is .50
1
processing frame: 1 setting is: 1.50 setsteps is .50
2
processing frame: 2 setting is: 2.00 setsteps is .50
3
processing frame: 3 setting is: 2.50 setsteps is .50
4
processing frame: 4 setting is: 3.00 setsteps is .50
5
processing frame: 5 setting is: 3.50 setsteps is .50
6
processing frame: 6 setting is: 4.00 setsteps is .50
7
processing frame: 7 setting is: 4.50 setsteps is .50
8
processing frame: 8 setting is: 5.00 setsteps is .50
9
processing frame: 9 setting is: 5.50 setsteps is .50
10
processing frame: 10 setting is: 6.00 setsteps is .50