Skip to content

Instantly share code, notes, and snippets.

View StevenAston's full-sized avatar

Steven Aston StevenAston

View GitHub Profile

Keybase proof

I hereby claim:

  • I am StevenAston on github.
  • I am stebe (https://keybase.io/stebe) on keybase.
  • I have a public key whose fingerprint is 5847 77AE 4B1F 8F35 65F4 F64E D8EB 35D6 4B6C 8D50

To claim this, I am signing this object:

@StevenAston
StevenAston / gist:7756726
Created December 2, 2013 19:44
Convert data to base64 and copy it to clipboard on OSX
2base64 () {
filename=$1;
extension="${filename##*.}";
filename="${filename%.*}";
footer='" />';
header='<img width="100%" border="0" src="data:image/'$extension';base64,';
echo 'Converting '$1' to Base64 string.';
data=$(openssl base64 -in $1);
echo $header$data$footer | pbcopy;
}
@StevenAston
StevenAston / 2base64
Created December 2, 2013 15:59
Convert all images in a folder into Base64 strings and create a file called Base64.txt containing said strings.
2base64 () {
if [ ! -f *.png ]; then
echo "No pngs."
else
for f in *.png; do
header='<img width="100%" border="0" src="data:image/png;base64,';
footer='" />';
echo 'Converting '$f' to Base64 string.';
data=$(openssl base64 -in $f);
echo $f >> base64.txt