dotfiles

My personal shell configs and stuff
git clone git://git.alex.balgavy.eu/dotfiles.git
Log | Files | Refs | Submodules | README | LICENSE

create_pocketbook_logo (1216B)


      1 #!/usr/bin/env bash
      2 # Converts an image to a Pocketbook-compatible version, for use e.g. as a screen saver image
      3 if ! command -v convert &> /dev/null; then
      4   echo "imagemagick not installed." >&2
      5   exit 1
      6 fi
      7 
      8 PARAMS=""
      9 
     10 while (( "$#" )); do
     11   case "$1" in
     12     -p|--palette)
     13       palette="$2"
     14       shift 2
     15       ;;
     16     -o|--output)
     17       outfile="$2"
     18       shift 2
     19       ;;
     20     -h|--help)
     21       echo "Usage:"
     22       echo "  create_pocketbook_logo [-p palette_file] input_file -o output_file"
     23       exit 0
     24       ;;
     25     --) #end arg parsing
     26       shift
     27       break
     28       ;;
     29     -*|--*=) # unsupported
     30       echo "Unsupported flag $1" >&2
     31       exit 1
     32       ;;
     33     *) # preserve positional arguments
     34       PARAMS="$PARAMS $1"
     35       shift
     36       ;;
     37   esac
     38 done
     39 eval set -- "$PARAMS"
     40 
     41 [ -z "$outfile" ] && echo "No output file supplied." >&2 && exit 1
     42 [ -z "$1" ] && echo "No file supplied.">&2 && exit 1
     43 [ -z "$palette" ] && ! [ -d /Volumes/PB627 ] && echo "No palette present.">&2 && exit 1
     44 convert "$1" \
     45   -background white \
     46   -alpha remove \
     47   -depth 8 \
     48   -colors 256 \
     49   -type grayscale \
     50   -remap "${palette:-/Volumes/PB627/system/logo/1_st.603.bmp}" \
     51   -dither FloydSteinberg \
     52   -compress none BMP3:"$outfile"