Вопрос

I would like to draw a line with imagemagick over several images using a bash for loop. I would like the line to be located in a slightly different place on each image. Unfortunately this spacing needs to be defined with decimal numbers i.e. I am | bc.

Ultimately, I would like my loop to look something like:

j=1
k=.3
for i in *.jpg
do
convert $i -draw "line $"(( $k + $j ))" | bc ,10 $"(( ($k + $j ))" | bc ,20" "${i%.*}line.jpg"

j=$(( $j + 1 ))

done

However, I can't even get this more simplified example to work:

convert $i -draw "line $"(( $j+2.1 ))" | bc ,581 $j, 514" test.jpg

Any ideas? Cheers for the help and info!

Это было полезно?

Решение

After much trial and error, the below creates incremental, decimal values in a bash for loop for use in the imagemagick utility, convert.

j=56
k=4.5111
for i in *.jpg
do
    p=$(echo "$j + $k" | bc) 
    convert $i -draw "line $p, 581 $p, 514" "${i%.*}.jpg"

    j=$(( $j + 1 ))
done
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top