#!/bin/bash # # if exists remove old pages directoryr and create a new one to put the pages in if [ -d pages ] then rm -r pages fi mkdir pages # wite all output in bold echo -en "\033[1;35m" # get current time seconds and minutes to use as random seed s=$(date +%S) m=$(date +%M) # set number of pages (200 for +50'000 words) pages=100 echo "pages:"$pages # create random number of times the stamp is applied (within a given reasonable range) stamps=$(awk -v s="$s" -v m="$m" 'BEGIN{srand(int(s*23/m));x=int(160+rand()*200); print x}') echo "stamps:"$stamps # init some counters r=0 j=0 # start creating pages until [ $j -gt $pages ] do # inform about current page being processed echo "page:"$j" of "$pages ((j+=1)) # create a blank and white a4 sized page echo "cretae empty page..." convert -size 2480x3508 xc:white page.png # init conter and get new random seeds values per page i=0 s=$(date +%S) m=$(date +%M) # create random center offset c=$(awk -v s="$s" -v m="$m" 'BEGIN{srand(s*m);x=rand()-0.5; print x}') echo "rand c:"$c # create random angle increase and desnity ir=$(awk -v s="$s" -v m="$m" 'BEGIN{srand(s);x=int(1+rand()*5); print x}') echo "rand ir:"$ir # create random smear factor e=$(awk -v s="$s" -v m="$m" 'BEGIN{srand(s*10-m);x=int(10+rand()*90); print x}') echo "rand e:"$e # cretae the circle composition echo "compose circle..." until [ $i -gt $stamps ] do # print iteration echo -en "\033[1B $i \033[1A\033[6D" # increase counters ((i+=1)) ((r+=ir)) # rotate base image magick orig.png -rotate $r -resize 350x350 copy.png # calculate the position cx=$(awk -v i="$i" -v c="$c" 'BEGIN{ out=2480*(0.5-0.8*c)+20*c*i; print out }') cy=$(awk -v i="$i" -v c="$c" -v e="$e" 'BEGIN{ out=3508*(0.5-0.9*c)+e*c*i; print out }') rx=$(awk -v i="$i" -v c="$c" 'BEGIN{ out=800+3*c*i; print out }') ry=$(awk -v i="$i" -v c="$c" 'BEGIN{ out=800+7*c*i; print out }') a=$(awk -v r="$r" 'BEGIN{ out=r/360*2*3.14159; print out }') x=$(awk -v cx="$cx" -v a="$a" -v rx="$rx" 'BEGIN {v=cx+rx*cos(a); print v }') y=$(awk -v cy="$cy" -v a="$a" -v ry="$ry" 'BEGIN {v=cy+ry*sin(a); print v }') # compose to a new image magick composite copy.png page.png -compose Multiply -geometry +$x+$y page.png done # move created pages to pages folder mv page.png ./pages/page$j.png done # create "unique" time stamp for book filename ts=$(date +%H%S%M) # convert and attach all pages into a pdf file convert ./pages/*.png ./book_$ts.pdf mv ./pages ./pages_$ts