Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
How to quickly create a "Convert to data URI" context menu option on Mac

Setup

  1. Download https://gist.github.com/jsocol/1089733 and unpack
  2. Rename data-uri.py to data-uri and copy to /usr/local/bin/
  3. Open Terminal, cd /usr/local/bin/ and and then chmod +x data-uri (enter password when prompted)
  4. Open Automator, choose New > Service.
  5. Set up the service as follows:
    Service receives selected files or folders in Finder.app
    which is connected to a Run Shell Script action, with the following settings:
    Shell: /bin/bash
    Pass input: as arguments
  for f 
  do
    /usr/local/bin/data-uri "$f" | pbcopy
  done

And save as convert-to-datauri
See http://grab.by/nuCE for a visual overview.

How to use

Right click on any file and select the convert-to-datauri option in the Services submenu. The data URI is copied to the clipboard and is ready to be pasted.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.