Skip to content

Instantly share code, notes, and snippets.

@quotepilgrim
Last active October 14, 2024 14:24
Show Gist options
  • Select an option

  • Save quotepilgrim/ddbe992c75880104176a589023115467 to your computer and use it in GitHub Desktop.

Select an option

Save quotepilgrim/ddbe992c75880104176a589023115467 to your computer and use it in GitHub Desktop.
#!/bin/sh
set -e
infile=$1
outfile="${infile%.*}.png"
width=$(($2 - 2))
bytes=$((width * width * 3))
cat "$infile" /dev/zero | head -c $bytes |
magick -depth 8 -size "$width"x"$width" rgb:- -separate +channel\
-swap 0,2 -combine -bordercolor Black -border 1x1 "$outfile"
#!/bin/sh
set -e
infile=$1
outfile="${infile%.*}.txt"
magick "$infile" -separate +channel -swap 0,2 -combine rgb:- |
tr -d '\000' >"$outfile"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment