Skip to content

Instantly share code, notes, and snippets.

@8bitDesigner
Created March 5, 2015 20:19
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 8bitDesigner/a50ffd7d49cf7da604fa to your computer and use it in GitHub Desktop.
Save 8bitDesigner/a50ffd7d49cf7da604fa to your computer and use it in GitHub Desktop.
Generating sized favicons from SVG
canvas32 = $('<canvas width=32 height=32>')
canvas16 = $('<canvas width=16 height=16>')
img = $('<img src="http://hampton.dev/assets/fs-logo-icon.svg">')
img.on('load', function() {
console.log('loaded')
ctx32 = canvas32[0].getContext('2d')
ctx32.drawImage(img[0], -4, 5, 39, 18)
$('body').append("<img src='"+canvas32[0].toDataURL("image/png")+"'>")
ctx16 = canvas16[0].getContext('2d')
ctx16.drawImage(img[0], -2, 3, 20, 9)
$('body').append("<img src='"+canvas16[0].toDataURL("image/png")+"'>")
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment