Skip to content

Instantly share code, notes, and snippets.

@kozie
Created October 28, 2013 12:08
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 kozie/7195761 to your computer and use it in GitHub Desktop.
Save kozie/7195761 to your computer and use it in GitHub Desktop.
Create Blue Transparent Base64 Img URL
var e = document.createElement("canvas")
var c = e.getContext("2d");
e.width = 1
e.height = 1
var d = c.getImageData(0, 0, 1, 1);
d.data[0] = 0; // R
d.data[1] = 92; // G
d.data[2] = 170; // B
d.data[3] = 222; // A
c.putImageData(d, 0, 0, 0, 0, 1, 1)
e.toDataURL()
// "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVQIW2NkiFl1DwADUAHmsr7HFwAAAABJRU5ErkJggg=="
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment