Skip to content

Instantly share code, notes, and snippets.

@Qix-
Last active January 30, 2016 10:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Qix-/561477a33c04a6a0f445 to your computer and use it in GitHub Desktop.
Save Qix-/561477a33c04a6a0f445 to your computer and use it in GitHub Desktop.
Convert anything to PNG
#!/bin/sh
SIZE=$(wc -c "$1" | awk '{print $1}')
SQUARE=$(bc <<< "sqrt( $SIZE / 3 ) + 1")
TOTAL=$(expr $SQUARE "*" $SQUARE "*" 3)
PAD=$(expr $TOTAL - $SIZE)
dd if=/dev/zero ibs=1 count=$PAD 2>/dev/null | cat $1 - | convert -size ${SQUARE}x${SQUARE} -depth 8 rgb:- -scale 200% $2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment