Skip to content

Instantly share code, notes, and snippets.

@gingerbeardman
Created May 1, 2023 16:29
Show Gist options
  • Save gingerbeardman/c19ac6d2b8565fea9e3e45909ddddc9b to your computer and use it in GitHub Desktop.
Save gingerbeardman/c19ac6d2b8565fea9e3e45909ddddc9b to your computer and use it in GitHub Desktop.
Convert a file to data-uri
#!/usr/bin/env bash
echo "url('data:$(file -bN --mime-type "$1");base64,$(base64 < "$1")')"
@gingerbeardman
Copy link
Author

Example usage: ./uri.sh image.png | pbcopy

Afterwards the data:image will be on the clipboard.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment