Фотографии отметки даты

У меня есть много фотографий на моем ПК, которые не имеют отметки времени на них в нижнем угле изображения.

Существует ли программа, которую я могу использовать для добавления отметки даты к этим фотографиям?

У меня есть человечность 16.04

2
задан 22 December 2016 в 02:51

1 ответ

Если можно установить 'phatch', который имеет хороший GUI, я настоятельно рекомендую этому. Однако мне не удалось установить его на моей человечности 16.04 даже с предложенным патчем.

Поэтому я начал искать замену это. 'ImageMagick' является тем, который я использую теперь. Это работает в командной строке (CLI), и файл сценария записан в просто задачу. Ниже файл сценария, который я записал. Смотрите и это могло бы помочь Вам. Измените его для удовлетворения потребности. Протестируйте его полностью, и можно скопировать файл сценария версии в /usr/local/sbin каталог для легкого доступа.

#!/bin/bash
# set destination directory
d_dir=im
# copy the destination directories structure only
# input source directory
s_dir=""
flag=0
until [ $flag == "1" ] ; do
  clear
  printf "\n"
  ls -d */
  printf  "\nEnter the name of one of the folders above to processed. \n\n"
  read s_dir  # input source directory
  ls -d */ | grep -wq $s_dir && flag=1 || echo printf "\nDirectory not exist!" ; sleep 2
done

printf  "\nCreating destination folder(s):  ./$d_dir/$s_dir\n"
rsync -avq -f"+ */" -f"- *" ./$s_dir ./$d_dir

#
# Overwrite the existing file(s)?
#

printf  "\nOverwrite existing file(s)?\n"
printf  "\nPress [Y/y] or [N/n] ... "
tput sc  # save the cursor current position

overwrite=""
until [ "$overwrite" = "y" -o "$overwrite" = "n" ] ; do
  read -s -n 1 overwrite  # printf n "\033[K"  erase to end of the line
  tput rc ; tput cub 1 ; tput el ; tput cuf 1  # restore cursor position, move 1 left, erase to end of the line , move 1 right
  printf  "$overwrite\b"        # \b --backspace
  overwrite=$(echo $overwrite | tr 'A-Z' 'a-z')  # translate to lower case
done
printf "\n\n"

#
# list file names in associated path
# find source_dir -type f -name \*.[Jj][Pp][Gg]
#

for img in $(find $s_dir -type f -name \*.[Jj][Pp][Gg] 2> /dev/null ) 
 do 
  if ! [ -f $d_dir/"$img" -a $overwrite = "n" ] ; then

# write and overwrite image file with date stamp 
# read exif meta-data from the image file

read ymd hms orient wid leng \
    <<< $(identify -format '%[exif:DateTimeOriginal]  \
    %[exif:Orientation] %[exif:ExifImageWidth] \
    %[exif:ExifImageLength]\n' $img)

year=${ymd:0:4}; mon=${ymd:5:2}; day=${ymd:8:2}
hour=${hms:0:2}; min=${hms:3:2}; sec=${hms:6:2}


# calculate the pointsize --- 3.5% of the smaller one --- width or length

if [ "$wid" -gt "$leng" ] ; then
    let ptsz=$leng*35/1000    # 35/1000 is from try and error
else
    let ptsz=$wid*35/1000
fi

#
# rotate image first according to the orientation
# rotate back(reverse) after process
#
# TopLeft - 1, BottomRight - 3, RightTop - 6, LeftBottom - 8
#    1
#  6   8    
#    3
#

case $orient in
  "1")
    rotate_1st="" 
    rotate_reverse=""
    let tx=$wid/100      # 100 is from try and error
    let ty=$leng/120     # 120 is from try and error

  ;;
  "8")
    rotate_1st='-rotate -90' 
    rotate_reverse='-rotate +90'
    let tx=50
    let ty=50
  ;;
  "3")
    # actually, I do not have photo with orientation 3, 
    # the tx and ty are just wild guess.
    rotate_1st='-rotate -180' 
    rotate_reverse='-rotate +180'
    let tx=$wid/100  
    let ty=$leng/120 
  ;;
  "6")
    # actually, I do not have photo with orientation 6, 
    # the tx and ty are just wild guess.
    rotate_1st='-rotate +90' 
    rotate_reverse='-rotate -90'
    let tx=50
    let ty=50
  ;;
esac

 convert "$img" \
    $rotate_1st \
    -gravity SouthEast \  # date stamp at bottom right of photo
    -pointsize $ptsz \
    -fill red \
    -font Ubuntu-Mono \
    -annotate +"$tx"+"$ty" "@ $hour:$min:$sec\n$year-$mon-$day" \
    $rotate_reverse \
    $d_dir/"$img" 

   printf "$d_dir/$img  converted.\n"
 fi
done
printf "Done! \n"
2
ответ дан 2 December 2019 в 03:43

Другие вопросы по тегам:

Похожие вопросы: