Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- #
- # 5 images (~ 10MB) takes ~16 seconds
- #
- # find /media/sf_test/ -type f -iname "*.jpg" -exec /root/imagick_script.sh "{}" \;
- #
- backgroundimage=$1
- bgp=/media/sf_test/
- # this is slow ...
- #ww=`convert "$backgroundimage" -format "%[fx:.20*w]" info:`
- #hh=`convert "$backgroundimage" -format "%[fx:.20*h]" info:`
- # "%[fx:w] %[fx:h] %[exif:DateTime]"
- dim=`identify -format "%[fx:.15*w] %[fx:.15*h] %[exif:DateTime]" "$backgroundimage"`
- ww=`echo $dim | awk '{print $1}'`
- hh=`echo $dim | awk '{print $2}'`
- ww=`printf "%.0f\n" "${ww}"`
- hh=`printf "%.0f\n" "${hh}"`
- if [ "$hh" -gt "$ww" ]
- then
- # echo "swap size"
- echo "original = $ww x $hh"
- #Diff=`expr $hh - $ww`
- #eval $(echo ww=$hh\;hh=$ww)
- #echo "new = $ww x $hh"
- #ww=`expr $ww + $Diff`
- #hh=`expr $hh + $Diff`
- let ww=$ww*2
- echo "new + diff = $ww x $hh"
- fi
- year=`echo $dim | awk '{print substr($3,1,4)}'`
- # i have images takin in range from 2006 to 2012, so if some exim data is removed, use year 2019..
- case "$year" in
- '2006')
- #
- ;;
- '2007')
- #
- ;;
- '2008')
- #
- ;;
- '2009')
- #
- ;;
- '2010')
- #
- ;;
- '2011')
- #
- ;;
- '2012')
- #
- ;;
- *)
- year=2019
- ;;
- esac
- if [ ! -f ${bgp}${year}.png ];
- then
- convert -gravity southeast -size 300x130 xc:transparent -font Courier-bold -pointsize 125 -fill red -draw "text 0,0 '${year}'" ${bgp}output.png
- composite ${bgp}output.png ${bgp}fons.png ${bgp}${year}.png
- #echo "${year}.png nav ..";
- fi
- Watermark=${bgp}${year}.png
- Fname="${backgroundimage##*/}"
- Fdir="${backgroundimage:0:${#backgroundimage} - ${#Fname}}"
- #echo "${Fdir}new_$Fname"
- echo "${ww}x$hh $1"
- composite -gravity southeast \( $Watermark -resize ${ww}x${hh} \) "$backgroundimage" "${Fdir}neew_$Fname"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement