]> git.nbdom.net Git - nb.git/commitdiff
jpg2avi, ls_img_black
authorNicolas Boisselier <nicolas.boisselier@gmail.com>
Fri, 7 Aug 2015 15:45:41 +0000 (16:45 +0100)
committerNicolas Boisselier <nicolas.boisselier@gmail.com>
Fri, 7 Aug 2015 15:45:41 +0000 (16:45 +0100)
etc/profile.d/functions

index 9c7e9c95109c22e27bb36f34ae8106d66ad3be20..e80cb0f312ae2bb7336c6259bdef4442c0007b47 100644 (file)
@@ -257,25 +257,39 @@ exec "mplayer",$_[1];
 ' "$@"
 }
 
+ls_img_black() {
+
+  declare threshold; threshold=10
+  shell_help_noarg "Usage: $FUNCNAME [-threshold PCENT (default: $threshold)] IMG1 IMG2 ..." "$@" && return
+
+  while [ $# -gt 0 ]; do
+    if [ "$1" = "-threshold" ]; then
+      threshold=$2; shift 2; continue
+    fi
+    #colors=$(convert $1 -format "%[mean]" info:-)
+    convert "$1" -threshold ${threshold}% -format %c histogram:info:- | grep -qm1 white || echo "$1"
+    shift
+  done
+}
+
 jpg2avi() {
 
   shell_help_noarg "Usage: $FUNCNAME [-h] JPG_FILES AVI_FILE" "$@" && return
   declare still; still=/tmp/$FUNCNAME.$$.txt; [ -x /dev/shm ] && tmp=/dev/shm/$FUNCNAME.$$.txt
-  #declare still; still=$FUNCNAME.txt
+
+  declare avi jpg
+
   declare tot; tot=$#
   declare count; count=0
 
-  declare avi; #avi=${@:$#}
-  declare jpg; #jpg=${@:1:$(($# - 1))}
-
   while [ $# -gt 0 ]; do
     count=$(($count+1))
 
     if [ "$count" = "$tot" ]; then
       avi="$1"; shift; break
     fi
-
     echo "$1" >> "$still"
+
     shift
   done
 
@@ -283,3 +297,5 @@ jpg2avi() {
   mencoder -nosound -ovc lavc -lavcopts vcodec=mpeg4:aspect=16/9:vbitrate=8000000 -vf scale=1920:1080 -mf type=jpeg:fps=24 mf://@${still} -o $avi
   rm -f "$still"
 }
+
+