Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

imoLV

By: a guest on Jan 16th, 2013  |  syntax: Bash  |  size: 1.76 KB  |  views: 25  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. #!/bin/bash
  2. #
  3. # 5 images (~ 10MB) takes ~16 seconds
  4. #
  5. # find /media/sf_test/ -type f -iname "*.jpg" -exec /root/imagick_script.sh "{}" \;
  6. #
  7.  
  8. backgroundimage=$1
  9. bgp=/media/sf_test/
  10.  
  11.  
  12. # this is slow ...
  13. #ww=`convert "$backgroundimage" -format "%[fx:.20*w]" info:`
  14. #hh=`convert "$backgroundimage" -format "%[fx:.20*h]" info:`
  15.  
  16. # "%[fx:w] %[fx:h] %[exif:DateTime]"
  17. dim=`identify -format "%[fx:.15*w] %[fx:.15*h] %[exif:DateTime]" "$backgroundimage"`
  18.  
  19. ww=`echo $dim | awk '{print $1}'`
  20. hh=`echo $dim | awk '{print $2}'`
  21. ww=`printf "%.0f\n" "${ww}"`
  22. hh=`printf "%.0f\n" "${hh}"`
  23.  
  24. if [ "$hh" -gt "$ww" ]
  25. then
  26. #    echo "swap size"
  27.     echo "original = $ww x $hh"
  28.     #Diff=`expr $hh - $ww`
  29.     #eval $(echo ww=$hh\;hh=$ww)
  30.     #echo "new = $ww x $hh"
  31.     #ww=`expr $ww + $Diff`
  32.     #hh=`expr $hh + $Diff`
  33.     let ww=$ww*2
  34.     echo "new + diff = $ww x $hh"
  35. fi
  36.  
  37. year=`echo $dim | awk '{print substr($3,1,4)}'`
  38.  
  39. # i have images takin in range from 2006 to 2012, so if some exim data is removed, use year 2019..
  40. case "$year" in
  41. '2006')
  42.     #
  43. ;;
  44. '2007')
  45.     #
  46. ;;
  47. '2008')
  48.     #
  49. ;;
  50. '2009')
  51.     #
  52. ;;
  53. '2010')
  54.     #
  55. ;;
  56. '2011')
  57.     #
  58. ;;
  59. '2012')
  60.     #
  61. ;;
  62. *)
  63.     year=2019
  64. ;;
  65. esac
  66.  
  67.  
  68. if [ ! -f ${bgp}${year}.png ];
  69. then
  70.     convert -gravity southeast -size 300x130 xc:transparent -font Courier-bold -pointsize 125 -fill red -draw "text 0,0 '${year}'" ${bgp}output.png
  71.     composite  ${bgp}output.png ${bgp}fons.png ${bgp}${year}.png
  72.     #echo "${year}.png nav ..";
  73. fi
  74.  
  75. Watermark=${bgp}${year}.png
  76.  
  77.  
  78. Fname="${backgroundimage##*/}"
  79. Fdir="${backgroundimage:0:${#backgroundimage} - ${#Fname}}"
  80. #echo "${Fdir}new_$Fname"
  81. echo "${ww}x$hh $1"
  82. composite -gravity southeast \( $Watermark -resize ${ww}x${hh} \) "$backgroundimage" "${Fdir}neew_$Fname"