Advertisement
metalx1000

script for Arduino TV output image to binary

Jun 22nd, 2016
663
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.40 KB | None | 0 0
  1. #!/bin/bash
  2. #GPLv3
  3. #get input image
  4. img=$1
  5.  
  6. #get image size
  7. size="$(identify $img|awk '{print $3}'|sed 's/x/,/g')"
  8.  
  9. echo "$size,"
  10.  
  11. echo -n "0b"
  12. convert $img txt:-|\
  13.   grep -v ImageMagick |\
  14.   while read line;
  15.   do
  16.     if [[ $line == *"white"* ]];
  17.     then
  18.       echo -n "1";
  19.     else
  20.       echo -n "0";
  21.     fi;
  22.   done|\
  23.   sed 's/\(.\{8\}\)/\1,\n0b/g'|grep -v "^0b$"|sed '$ s/.$//'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement