Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- Help() {
- # echo "Write in format: $0 -od [Original directory] -t [text] -rd [Result directory] -n [font name] -s [font size]
- echo "Usage: $0 [OPTIONS]"
- echo "[OPTIONS] is following"
- echo "-od/--originaldir Original directory with files"
- echo "-t/--text Text, which you will see in images"
- echo "-rd/--resultdir Directory with result images"
- echo "-n/--fontname Name of font"
- echo "-s/--fontsize Size of font"
- echo "-h/--help Help messages"
- exit
- }
- count_of_arguments=$#
- while [ $# -gt 0 ]; do
- case "$1" in
- -od|--originaldir)
- original_dir="$2"
- shift 2
- ;;
- -t|--text)
- text="$2"
- shift 2
- ;;
- -rd|--resultdir)
- result_dir="$2"
- shift 2
- ;;
- -n|--fontname)
- font_name="$2"
- shift 2
- ;;
- -s|--fontsize)
- font_size="$2"
- shift 2
- ;;
- -h|--help)
- Help
- ;;
- *)
- break
- ;;
- esac
- done
- if [[ ${count_of_arguments}<6 || ${count_of_arguments} == 0 ]]; then
- echo "Wrong arguments!"
- echo "Write: $0 -h or $0 --help"
- exit
- fi
- if [[ ! -d ${original_dir} ]]; then
- echo "There is no such directory ${original_dir}"
- exit
- fi
- echo fuck1
- if [[ ! -d ${result_dir} ]]; then
- mkdir -p ${result_dir}
- fi
- echo fuck2
- font=${font_name:=AvantGarde-Book}
- check_font=$(convert -list font | grep Font: | grep "$font")
- if [[ $check_font == "" ]]; then
- echo " There is no such font ${font} in libraries"
- exit
- fi
- size=${size_font:=14}
- for files in $original_dir/*.jpg; do
- width=`identify "$files" | cut -d '.' -f 3 | cut -d "x" -f 1`
- result=`basename ${files} | cut -d '.' -f 1`
- result=${result}_annotated.jpg
- convert -background '#0000' -font ${font} -size ${width}х${size} caption:"${text}" "${files}" +swap -composite -gravity SouthEast $files $result_dir/$result
- done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement