Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- #------------------------------------------------
- # A way to send images over thin text-based
- # mediums.
- #
- # This one is "fromgreytext.sh"
- # get "togreytext.sh" here: https://pastebin.com/XLFaVVdB
- #
- # Following the concept of SSTV (Slow Scan TV),
- # that images do not need to be perfect or large
- # when transmitted over thin mediums, I have made
- # This pair of scripts.
- #
- # The first one, "togreytext.sh" converts an image
- # into a small 26-grays grayscale image composed
- # of a substitution of letters for numbers in a PGM
- # uncompressed image file.
- #
- # ./togreytext.sh "infile.jpg" 128
- #
- # This "compressed" PGM can then be sent over LoRa
- # or text transmission methods.
- #
- # Once on the other side, "fromgreytext.sh" can
- # be run on the resulting file. It will expand
- # the letter back into numbers and set the
- # header correctly again.
- #
- # ./fromgreytext.sh captured.txt>outfile.pgm
- #
- # That file is then a valid uncompressed PGM
- # though grayscale and smaller than the original.
- # That PGM can then be converted to your image
- # format of choice.
- #
- # ~HowToPhil 2024/02/21 00:04 EST
- #------------------------------------------------
- # Put the args in pretty vars
- FILE="$1"
- # Expand the header into a proper line-returned pgm header
- head -n 1 "$FILE" |tr [:space:] "\n"; echo
- # Expand the letters into their "clamped" grayscale values
- cat "$FILE"|tail -n +1|sed 's/./& /g'\
- |sed "s/A/0/g"\
- |sed "s/B/10/g"\
- |sed "s/C/20/g"\
- |sed "s/D/30/g"\
- |sed "s/E/40/g"\
- |sed "s/F/50/g"\
- |sed "s/G/60/g"\
- |sed "s/H/70/g"\
- |sed "s/I/80/g"\
- |sed "s/J/90/g"\
- |sed "s/K/100/g"\
- |sed "s/L/110/g"\
- |sed "s/M/120/g"\
- |sed "s/N/130/g"\
- |sed "s/O/140/g"\
- |sed "s/P/150/g"\
- |sed "s/Q/160/g"\
- |sed "s/R/170/g"\
- |sed "s/S/180/g"\
- |sed "s/T/190/g"\
- |sed "s/U/200/g"\
- |sed "s/V/210/g"\
- |sed "s/W/220/g"\
- |sed "s/X/230/g"\
- |sed "s/Y/240/g"\
- |sed "s/Z/255/g"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement