|
| 1 | +#!/usr/bin/env bash |
| 2 | +# |
| 3 | +# Copyright 2025 8dcc. All Rights Reserved. |
| 4 | +# |
| 5 | +# This file is part of bin-graph. |
| 6 | +# |
| 7 | +# This program is free software: you can redistribute it and/or modify it under |
| 8 | +# the terms of the GNU General Public License as published by the Free Software |
| 9 | +# Foundation, either version 3 of the License, or (at your option) any later |
| 10 | +# version. |
| 11 | +# |
| 12 | +# This program is distributed in the hope that it will be useful, but WITHOUT |
| 13 | +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| 14 | +# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more |
| 15 | +# details. |
| 16 | +# |
| 17 | +# You should have received a copy of the GNU General Public License along with |
| 18 | +# this program. If not, see <https://www.gnu.org/licenses/>. |
| 19 | +# |
| 20 | +# ----------------------------------------------------------------------------- |
| 21 | +# |
| 22 | +# Simple script for generating multiple binary graphs from the same file. |
| 23 | +set -e |
| 24 | + |
| 25 | +BIN_GRAPH='bin-graph' |
| 26 | + |
| 27 | +if [ $# -ne 1 ]; then |
| 28 | + echo "Usage: $(basename "$0") INPUT" 1>&2 |
| 29 | + exit 1 |
| 30 | +fi |
| 31 | + |
| 32 | +assert_cmd() { |
| 33 | + if [ ! "$(command -v "$1")" ]; then |
| 34 | + echo "$(basename "$0"): The '$1' command is not installed." 1>&2 |
| 35 | + exit 1 |
| 36 | + fi |
| 37 | +} |
| 38 | + |
| 39 | +assert_cmd "$BIN_GRAPH" |
| 40 | + |
| 41 | +input_file="${*: -1}" |
| 42 | + |
| 43 | +# Command-line options for each mode. |
| 44 | +"$BIN_GRAPH" --mode 'grayscale' "$input_file" "${input_file}.grayscale.png" |
| 45 | +"$BIN_GRAPH" --mode 'ascii' "$input_file" "${input_file}.ascii.png" |
| 46 | +"$BIN_GRAPH" --mode 'entropy' --transform-squares 16 "$input_file" "${input_file}.entropy.png" |
| 47 | +"$BIN_GRAPH" --mode 'histogram' "$input_file" "${input_file}.histogram.png" |
| 48 | +"$BIN_GRAPH" --mode 'bigrams' "$input_file" "${input_file}.bigrams.png" |
| 49 | +"$BIN_GRAPH" --mode 'dotplot' --offset-start 0 --offset-end 1000 "$input_file" "${input_file}.dotplot1.png" |
| 50 | +"$BIN_GRAPH" --mode 'dotplot' --offset-start 4000 --offset-end 5000 "$input_file" "${input_file}.dotplot2.png" |
| 51 | +"$BIN_GRAPH" --mode 'dotplot' --offset-start 10000 --offset-end 11000 "$input_file" "${input_file}.dotplot3.png" |
| 52 | +"$BIN_GRAPH" --mode 'dotplot' --offset-start 30000 --offset-end 31000 "$input_file" "${input_file}.dotplot4.png" |
0 commit comments