Advertisement
Guest User

bin-to-png.sh

a guest
Jul 19th, 2021
294
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/bin/env bash
  2. #>okay. so how do I automate binary data into an image?
  3. # usage: script.sh <input> [<output>]
  4. if [ ! "$1" ]; then echo Specify an input.; exit; fi
  5. if [ ! -e "$1" ]; then echo \"$1\" doesn\'t exist.; exit; fi
  6. if [ "$2" ]; then output="${2%.*}.png"; else output="${1%.*}.png"; fi
  7. if [ -e "$output" ]; then echo Output exists, specify another name.; exit; fi
  8. size=$(bc <<< "sqrt($(stat -c%s "$1")/8)+0.5/1")
  9. cat "$1" /dev/zero - | ffmpeg -f rawvideo -s ${size}:${size} -pix_fmt rgba64be -i - -vframes 1 "$output"
  10. echo Playback with\:
  11. echo ffmpeg -i \"$output\" -f rawvideo - \| mpv -
Advertisement
Advertisement
Advertisement
RAW Paste Data Copied
Advertisement